WARNING:|WARNING: POSSIBLE DNS SPOOFING DETECTED!

【WARNING:|WARNING: POSSIBLE DNS SPOOFING DETECTED!】昨天公司的 GIT 仓库做了一次数据迁移,今天更新代码的时候就失败了。

localhost:project-name User$ git branch develop * master localhost:project-name User$ git pull @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @WARNING: POSSIBLE DNS SPOOFING DETECTED!@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ The RSA host key for www.abc.git has changed, and the key for the corresponding IP address 10.128.1.1 is unknown. This could either mean that DNS SPOOFING is happening or the IP address for the host and its host key have changed at the same time. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @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:SE1vmakE1lKMgsO+jNW11CPnaraDarWcKaSaSs111ta. 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:18 RSA host key for www.abc.git 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.

整体提示信息如上图所示,关于隐私部分,做了单词及数字的修改和替换,参考大概意思即可。
这不是什么太复杂的问题,也比较常见,一般是修改了服务器的映射引起的。
解决方法如下:
首先找到下图的两行代码:
RSA host key for (这里的地址就是要解决的问题)
Offending RSA key in /Users/User/.ssh/known_hosts:18 RSA host key for www.abc.git has changed and you have requested strict checking.

找到地址 www.abc.git 以后,执行以下代码:ssh-keygen -R IP地址
如果IP地址后面有端口,就把端口加上,ssh-keygen -R IP地址:9090
localhost:project-name User$ ssh-keygen -R www.abc.git # Host www.abc.git found: line 18 /Users/User/.ssh/known_hosts updated. Original contents retained as /Users/User/.ssh/known_hosts.old

执行完该行代码以后,命令行会有一样交互提示,输入“yes”以后相应文件更新,即成功了,此时再重新做之前需要的操作即可,比如 git pull 更新代码等。

    推荐阅读