Skip to main content

此版本的 GitHub Enterprise 将停止服务 2023-01-18. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Accessing the administrative shell (SSH)

SSH 访问可让您运行 GitHub Enterprise Server 命令行实用程序,以进行故障排除、运行备份及配置复制。

About administrative shell access

If you have SSH access to the administrative shell, you can run GitHub Enterprise Server's command line utilities. SSH access is also useful for troubleshooting, running backups, and configuring replication. Administrative SSH access is managed separately from Git SSH access and is accessible only via port 122.

Enabling access to the administrative shell via SSH

To enable administrative SSH access, you must add your SSH public key to your instance's list of authorized keys. For more information, see "Generating a new SSH key and adding it to the ssh-agent."

Tip: Changes to authorized SSH keys take effect immediately.

  1. 从 GitHub Enterprise Server 上的管理帐户任意页面的右上角,单击

    用于访问站点管理员设置的火箭图标的屏幕截图

  2. 如果你尚未在“站点管理员”页上,请在左上角单击“站点管理员”。

    “站点管理员”链接的屏幕截图

  3. 在左侧边栏中,单击“管理控制台”。 左侧边栏中的 管理控制台 选项卡

  4. Under "SSH access", paste your key into the text box, then click Add key. Text box and button for adding an SSH key

  5. 在左侧边栏下,单击“保存设置”。

    管理控制台 中的“保存设置”按钮的屏幕截图

    注意:保存 管理控制台 中的设置会重启系统服务,这可能会导致用户可察觉的停机时间。

  6. 等待配置运行完毕。

    配置实例

Connecting to the administrative shell over SSH

After you've added your SSH key to the list, connect to the instance over SSH as the admin user on port 122.

$ ssh -p 122 admin@github.example.com
Last login: Sun Nov 9 07:53:29 2014 from 169.254.1.1
admin@github-example-com:~$ █

Troubleshooting SSH connection problems

If you encounter the Permission denied (publickey) error when you try to connect to your GitHub Enterprise Server instance via SSH, confirm that you are connecting over port 122. You may need to explicitly specify which private SSH key to use.

To specify a private SSH key using the command line, run ssh with the -i argument.

ssh -i /path/to/ghe_private_key -p 122 admin@HOSTNAME

You can also specify a private SSH key using the SSH configuration file (~/.ssh/config).

Host HOSTNAME
  IdentityFile /path/to/ghe_private_key
  User admin
  Port 122

Accessing the administrative shell using the local console

In an emergency situation, for example if SSH is unavailable, you can access the administrative shell locally. Sign in as the admin user and use the password established during initial setup of GitHub Enterprise Server.

Access limitations for the administrative shell

Administrative shell access is permitted for troubleshooting and performing documented operations procedures only. Modifying system and application files, running programs, or installing unsupported software packages may void your support contract. Please contact GitHub Enterprise 支持 if you have a question about the activities allowed by your support contract.