问题描述
某一打开一个git项目向github,代码的时候提示
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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.
解决方案
根据描述我们可以知道是known_hosts中的host key发生了改变。
ssh-keygen -R github.com #让ssh自动去更新一下hosts地址
git push #重新推送一下代码
在重新推送代码的过程中,页面上会提示是否要重新建立连接,输入yes,即可正常推送代码
The authenticity of host 'github.com (20.201.28.151)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?
问题分析
https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/
详细来说,github.com的RSA SSH私钥在GitHub存储库中被意外地公开了。由于这可能会带来安全问题,GitHub决定用新生成的密钥替换受损的SSH密钥。所以我们需要重新更新一下host key。
参考文章
how-to-deal-with-the-remote-host-identification-has-changed-message-with-github