问题描述
今天在向Github仓库同步代码时遇到了 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
这个告警。
问题出现的环境背景及自己尝试过哪些方法
尝试删除了当前用户目录下 .ssh
下的 known_hosts
文件。重新使用 GitLens
同步代码,并没有起效。
后来尝试在终端中手动执行 Git pull
命令成功拉取了更新。但是提示了 Are you sure you want to continue connecting (yes/no)?
的确认操作。
相关代码
> git pull @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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:xxx. 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. fatal: Could not read from remote repository.
你期待的结果是什么?实际看到的错误信息又是什么?
为什么出现了这样的情况?以及正确处理错误的方式。
回答:
看起来是 Github 更新了 SSH 主机密钥,? We updated our RSA SSH host key | The GitHub Blog
使用 ssh-keygen -R github.com
这个命令来删除旧的密钥后,更新一下 GitHub 新的 RSA SSH 密钥即可。具体更新方式在上一个链接中有提到。
