{"meta":{"title":"测试 SSH 连接","intro":"设置 SSH 密钥并将其添加到 GitHub 后，可以测试连接。","product":"身份验证","breadcrumbs":[{"href":"/zh/enterprise-server@3.22/authentication","title":"身份验证"},{"href":"/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh","title":"使用 SSH 进行连接"},{"href":"/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection","title":"测试 SSH 连接"}],"documentType":"article"},"body":"# 测试 SSH 连接\n\n设置 SSH 密钥并将其添加到 GitHub 后，可以测试连接。\n\n测试 SSH 连接之前，应已完成以下各项：\n\n* [检查现有 SSH 密钥](/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys)\n* [生成新 SSH 密钥](/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)\n* [向 GitHub 帐户添加了新的 SSH 密钥](/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)\n\n需要使用密码（即之前创建的 SSH 密钥密码）来验证此操作。 请参阅“[使用 SSH 密钥密码](/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases)”。\n\n1. 打开<span class=\"platform-mac\">终端</span><span class=\"platform-linux\">终端</span><span class=\"platform-windows\">Git Bash</span>。\n\n2. 输入以下内容：\n\n   ```shell copy\n   ssh -T git@HOSTNAME\n   # Attempts to ssh to GitHub\n   ```\n\n   您可能会看到类似如下的警告：\n\n   ```shell\n   > The authenticity of host 'HOSTNAME (IP ADDRESS)' can't be established.\n   > ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.\n   > Are you sure you want to continue connecting (yes/no)?\n   ```\n\n3. 验证所看到消息中的指纹是否与 企业的公钥指纹匹配。 如果是，则键入 `yes`：\n\n   ```shell\n   > Hi USERNAME! You've successfully authenticated, but GitHub does not\n   > provide shell access.\n   ```\n\n   <div class=\"ghd-tool linux\">\n\n   你可能会看到此错误消息：\n\n   ```shell\n   ...\n   Agent admitted failure to sign using the key.\n   debug1: No more authentication methods to try.\n   Permission denied (publickey).\n   ```\n\n   这是某些 Linux 发行版的已知问题。 有关详细信息，请参阅“[错误：代理承认没有签署](/zh/enterprise-server@3.22/authentication/troubleshooting-ssh/error-agent-admitted-failure-to-sign)”。\n\n   </div>\n\n   > \\[!NOTE]\n   > 远程命令应以代码 1 退出。\n\n4. 验证生成的消息包含您的用户名。 如果收到“权限被拒绝”消息，请参阅“[错误：权限被拒绝（公钥）](/zh/enterprise-server@3.22/authentication/troubleshooting-ssh/error-permission-denied-publickey)”。"}