【发布时间】:2022-01-14 20:32:43
【问题描述】:
我在 github 上使用 ssh 密钥已经有一段时间了。突然我无法推动,我得到了Permission denied (publickey) error.
到目前为止,这是我尝试过的:
- 已检查 ssh 密钥是否在正确的目录中 (
~/.ssh) - 尝试将我的公钥重新上传到 github(我收到一条消息说密钥已经存在)
- 仔细检查我系统上
ssh-add -l -E sha256的输出是否与我在我的github 帐户上的ssh 设置中的字符串一致 - 遵循 github 文档的“ssh 故障排除”部分中的所有步骤。 (一切似乎都是 gucci)
- 用头撞墙一个小时
到目前为止,没有任何帮助。这是我最后的手段。我将不胜感激任何和所有的建议。这是我的ssh -vT git@github.com的输出
OpenSSH_7.2p2 Ubuntu-4ubuntu2.10, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/MY_USER_NAME/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [140.82.114.3] port 22.
debug1: Connection established.
debug1: identity file /home/MY_USER_NAME/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MY_USER_NAME/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.10
debug1: Remote protocol version 2.0, remote software version babeld-fb957b4d
debug1: no match: babeld-fb957b4d
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
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 /home/MY_USER_NAME/.ssh/known_hosts:4
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
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,sk-ssh-ed25519-cert-v01@openssh.com,sk-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,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@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 RSA public key: /home/MY_USER_NAME/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/MY_USER_NAME/.ssh/id_dsa
debug1: Trying private key: /home/MY_USER_NAME/.ssh/id_ecdsa
debug1: Trying private key: /home/MY_USER_NAME/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
更新: 我在使用具有不同密钥集的不同 github 帐户时遇到了同样的问题。同一台电脑。
【问题讨论】:
-
希望这个链接能帮助你克服这个问题。 stackoverflow.com/questions/9960897/…
-
SSH 告诉你它找不到对应于
id_rsa:debug1: identity file /home/MY_USER_NAME/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory的公钥。此外,在提供 id_rsa 密钥后,ssh 服务器没有响应“身份验证成功”。您是否绝对、肯定、100% 确定您已将正确的相应公钥上传到 github? -
正如@kalatabe 所说:
debug1: identity file /home/MY_USER_NAME/.ssh/id_rsa type 1表示 ssh 已找到.ssh/id_rsa。但debug1: key_load_public: No such file or directory表示 ssh 没有 找到.ssh/id_rsa.pub- 与此私钥一起使用的公钥。目前尚不清楚为什么没有找到它,因为ssh-keygen会成对生成它们,但我怀疑代理设置有问题。 -
@kalatabe “key_load_public”错误是指列表中的下一个键,而不是前一个键。 ssh 找到 id_rsa,但没有找到 id_rsa-cert 等
-
@kalatabe 我仔细检查了一下,公钥就在那里。另外,我有点新手,所以如果我错了,请纠正我,但我的印象是你不需要公钥来进行身份验证。只要您的服务器有公钥(github 有),它就是用于身份验证的私钥。