Skip to main content

Checking for existing SSH keys

Before you generate an SSH key, you can check to see if you have any existing SSH keys.

注意: GitHub 在 2022 年 3 月 15 日通过删除较旧的不安全密钥类型提高了安全性。

从该日期起,不再支持 DSA 密钥 (ssh-dss)。 您无法将新 DSA 密钥添加到您在 GitHub.com 上的个人帐户。

在 2021 年 11 月 2 日之前 valid_after 的 RSA 密钥 (ssh-rsa) 可以继续使用任何签名算法。 在该日期之后生成的 RSA 密钥必须使用 SHA-2 签名算法。 某些较旧的客户端可能需要升级才能使用 SHA-2 签名。

  1. 打开 Terminal(终端)Terminal(终端)Git 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 Cloud are one of the following.

    • id_rsa.pub
    • id_ecdsa.pub
    • id_ed25519.pub

    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, id_rsa.pub and id_rsa) that you would like to use to connect to GitHub Enterprise Cloud, 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."