跳至主要内容

测试您的 SSH 连接

在您设置了 SSH 密钥并将其添加到 GitHub 后,您可以测试连接。

平台导航

在测试 SSH 连接之前,您应该已经

您需要使用您的密码(即之前创建的 SSH 密钥短语)对该操作进行身份验证。参见 使用 SSH 密钥短语

  1. 打开 终端终端Git Bash

  2. 输入以下内容

    Shell
    ssh -T git@github.com
    # Attempts to ssh to GitHub
    

    您可能会看到类似的警告

    > The authenticity of host 'github.com (IP ADDRESS)' can't be established.
    > ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
    > Are you sure you want to continue connecting (yes/no)?
    
  3. 确保您看到的消息中的指纹与 GitHub 的公钥指纹 相匹配。如果匹配,请输入 yes

    > Hi USERNAME! You've successfully authenticated, but GitHub does not
    > provide shell access.
    

    您可能会看到此错误信息

    ...
    Agent admitted failure to sign using the key.
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    

    这是某些 Linux 发行版已知的问题。更多信息,请参阅 错误:代理承认签名失败

    注意

    远程命令应以代码 1 退出。

  4. 确认结果消息中包含您的用户名。如果收到 “permission denied” 的信息,请参阅 错误:权限被拒绝(publickey)

提示

如果您在不同的域(例如 octocorp.ghe.com)访问 GitHub,则需要将 git@github.com 替换为 octocorp@octocorp.ghe.com

ssh -T octocorp@octocorp.ghe.com
# Attempts to ssh to octocorp.ghe.com
© . This site is unofficial and not affiliated with GitHub, Inc.