【发布时间】:2021-02-07 22:32:01
【问题描述】:
我已关注the GitHub Docs instructions,了解如何创建 SSH 密钥并将其添加到信件中,从生成新密钥到将其添加到我的 GitHub 帐户。
我正在使用 Git Bash 在 Win10 上执行此操作。我已成功生成 RSA 密钥对,已添加到 ssh-agent,我已将公钥复制粘贴到我的 GitHub 帐户中,没有任何多余的空格等。
当我进入“测试您的 SSH 连接”阶段时,命令 ssh -T git@github.com 返回 git@github.com: Permission denied (publickey).
我已经阅读了this page 上的所有故障排除建议,但这些修复似乎都无法解决问题。
我的命令ssh -i ~/.ssh/id_rsa -vT git@github.com 的输出如下:
OpenSSH_8.4p1, OpenSSL 1.1.1i 8 Dec 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
debug1: identity file /c/Users/USER/.ssh/id_rsa type 0
debug1: identity file /c/Users/USER/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4
debug1: Remote protocol version 2.0, remote software version babeld-c34a939f
debug1: no match: babeld-c34a939f
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/USER/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/USER/.ssh/id_rsa RSA SHA256:sfCBsdTYd4G3HCltcpNdV68RksreyBB8vruHjzLHkxM explicit agent
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/USER/.ssh/id_rsa RSA SHA256:sfCBsdTYd4G3HCltcpNdV68RksreyBB8vruHjzLHkxM explicit agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
将ssh 命令中-i 之后的路径替换为~/.ssh/id_rsa.pub 会产生相同的结果。
有人可以帮我找出这里出了什么问题吗?
【问题讨论】: