Skip to main content

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

检查现有 SSH 密钥

在生成 SSH 密钥之前,您可以检查是否有任何现有的 SSH 密钥。

Platform navigation

About SSH keys

You can use SSH to perform Git operations in repositories on your GitHub Enterprise Server instance. For more information, see "About SSH."

If you have an existing SSH key, you can use the key to authenticate Git operations over SSH.

Checking for existing SSH keys

Before you generate a new SSH key, you should check your local machine for existing keys.

Note: By default with GitHub Enterprise Server 3.6 and later, as of the cutoff date of midnight UTC on August 1, 2022, SSH connections that satisfy both of the following conditions will fail.

  • The RSA key was added to a user account on your GitHub Enterprise Server instance after the cutoff date of midnight UTC on August 1, 2022.
  • The SSH client signs the connection attempt with the SHA-1 hash function.

GitHub Enterprise Server 3.6 and later also does not support SSH connections that use DSA, HMAC-SHA-1, or CBC ciphers. RSA SSH keys uploaded before the cutoff date can continue to authenticate using the SHA-1 hash function as long as the key remains valid. For more information about finding the version of GitHub Enterprise Server that you use, see "About versions of GitHub Docs."

Your site administrator can adjust the cutoff date for connections using RSA-SHA-1, and may block all connections using RSA-SHA-1. For more information, contact your site administrator or see "Configuring SSH connections to your instance."

  1. Open TerminalTerminalGit Bash.

  2. Enter ls -al ~/.ssh to see if existing SSH keys are present.

    $ ls -al ~/.ssh
    # Lists the files in your .ssh directory, if they exist
  3. Check the directory listing to see if you already have a public SSH key. By default, the filenames of supported public keys for GitHub Enterprise Server are one of the following.


    Tip: If you receive an error that ~/.ssh doesn't exist, you do not have an existing SSH key pair in the default location. You can create a new SSH key pair in the next step.

  4. Either generate a new SSH key or upload an existing key.

    • If you don't have a supported public and private key pair, or don't wish to use any that are available, generate a new SSH key.

    • If you see an existing public and private key pair listed (for example, and id_rsa) that you would like to use to connect to GitHub Enterprise Server, you can add the key to the ssh-agent.

      For more information about generation of a new SSH key or addition of an existing key to the ssh-agent, see "Generating a new SSH key and adding it to the ssh-agent."