git push 提交代码报错 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
个人项目遇到的问题,几天没提交代码了,今天做了些优化,准备提交到 github 时出现了问题,错误提示信息如下:
PS D:\workspace\qianduan.shop> git push
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:uNiVztksCsDhcc0u9e8*****************.
Please contact your system administrator.
Add correct host key in /c/Users/admin/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/admin/.ssh/known_hosts:2
RSA 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.
如何解决
通过分析错误提示,发现远程主机发送的SHA256值与之前存放于/.ssh/known_hosts不一致,通过删除known_hosts解决。
还有个简单的办法,执行 ssh-keygen -R gitHub.com 命令即可:
C:\Users\admin>ssh-keygen -R github.com
Host github.com found: line 2
C:\Users\admin/.ssh/known_hosts updated.
Original contents retained as C:\Users\admin/.ssh/known_hosts.old
然后再次 git push 推送代码:
PS D:\workspace\qianduan.shop> git push
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Warning: Permanently added 'github.com' (ECDSA) to the list of known hosts.
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '20.205.243.166'
Offending key for IP in /c/Users/admin/.ssh/known_hosts:5
Are you sure you want to continue connecting (yes/no)? yes
Enumerating objects: 88, done.
Counting objects: 100% (88/88), done.
Delta compression using up to 12 threads
Compressing objects: 100% (56/56), done.
Writing objects: 100% (56/56), 9.83 KiB | 1006.00 KiB/s, done.
Total 56 (delta 38), reused 0 (delta 0)
remote: Resolving deltas: 100% (38/38), completed with 25 local objects.
remote: This repository moved. Please use the new location:
remote: git@github.com:believeyourself/blogs.git
remote:
remote: GitHub found 52 vulnerabilities on believeyourself/blogs's default branch (11 critical, 24 high, 15 moderate, 2 low). To find out more, visit:
remote: https://github.com/believeyourself/blogs/security/dependabot
remote:
To github.com:believeyourself/qianduan.shop.git
6c06be5..9531285 master -> master