github 解决推拉代码提示 REMOTE HOST IDENTIFICATION HAS CHANGED 失败
1. 背景
在拉取github上一个新项目的时候爆出 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
第一反应是电脑被黑了,传说中的中间人攻击(题外话一下,其实所有的代理软件都算是中间人哦~),稍微检查了一下,应该不是。仔细看内容,有点意思。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 /c/Users/lindexi/.ssh/known_hosts to get rid of this message. Offending RSA key in /c/Users/lindexi/.ssh/known_hosts:2 Host key for github.com has changed and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
法1:
ssh-keygen -R github.com
- 命令行删除旧的github公钥
ssh-keygen -R github.com
- 然后直接继续拉代码就行了,需要重新信任一下github的fingerprint
法2:
最简单的方式就是删除上面提到的 known_hosts
文件,例如我的文件是 /c/Users/lindexi/.ssh/known_hosts
路径,直接使用 rm 命令删除,代码如下
rm /c/Users/lindexi/.ssh/known_hosts
还请在你电脑上执行以上命令的时候,替换为你自己的电脑上的路径
The authenticity of host 'github.com (20.205.243.166)' 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])?
执行完成之后,重新推拉代码,可以看到提示信息,只需要输入 yes 回车即可
以上步骤就是在将 github 添加到 known_hosts
文件里
也就是下一次推拉代码就不需要再次执行以上步骤
为什么有这样的事情呢?这是因为在 2023.03.24 更换了 GitHub 的 RSA 的 Key 值。因为 GitHub 团队发现自己的 Key 泄露了。
详细请看 We updated our RSA SSH host key The GitHub Blog
声明 欢迎转载,但请保留文章原始出处:) 博客园:https://www.cnblogs.com/chenxiaomeng/
如出现转载未声明 将追究法律责任~谢谢合作
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
2021-05-27 【pytest学习10】pytest报告,html,allure
2021-05-27 jira&confluence之什么是epic/feature/story/task
2021-05-27 【pytest学习9】usefixture的简单使用
2021-05-27 【pytest学习8】pytest的autouse参数
2021-05-27 【pytest学习7】fixture的重命名
2021-05-27 【pytest学习6】fixture的作用范围