目录

  • 问题描述
  • 解决办法
  • 参考文章

问题描述

使用git push 如往常一样推送代码,报错如下,开始以为是网络又出问题了,没有在意

过了很长时间,githu可以正常打开,不过代码还是推送失败,于是发现这个肯定是异常

$ 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:uNiVztksCsDhxc0u1e8BujQXVUxKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /Users/user/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/user/.ssh/known_hosts:1
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.

解决办法

将提示有问题的那一行删除

$ ssh-keygen -R github.com
# Host github.com found: line 1
/Users/user/.ssh/known_hosts updated.
Original contents retained as /Users/user/.ssh/known_hosts.old

重新推送代码,会有一些问题提示,都回答yes即可正常推送代码

参考文章

  • git push时报错:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!