提问者:小点点

尝试运行git命令[duplicate]时,Github SSH主机验证失败


当尝试对Github运行任何git命令(获取、拉取、推送等)时,会显示类似于以下内容的主机验证失败消息:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in ~/.ssh/known_hosts to get rid of this message.
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.

共2个答案

匿名用户

GitHub的rsa ssh主机令牌有问题

请参阅下面的文章来解决这个问题

https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/

匿名用户

根据Github的博客文章,他们的SSH密钥被泄露,因此他们重新生成了密钥。

您需要通过运行以下命令来删除存储的密钥:

$ ssh-keygen -R github.com

它应该会输出如下内容:

# Host github.com found: line 1
/Users/<username>/.ssh/known_hosts updated.

随后是获取新密钥的命令:

$ curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts

完成后,您可以重新运行您正在尝试的 git 命令。