git push失败:Push failed REMOTE HOST IDENTIFICATION HAS CHANGED

我会带着你远行 2023-10-05 12:24 183阅读 0赞

最近有一次 git push 时有报错,异常信息如下:

异常信息

  1. Push failed
  2. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  3. @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
  4. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  5. IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
  6. Someone could be eavesdropping on you right now (man-in-the-middle attack)!
  7. It is also possible that a host key has just been changed.
  8. The fingerprint for the ECDSA key sent by the remote host is
  9. SHA256:LmUqV5cIfDvU2tDCJjX1iwyDnDZ6KflqT+vH7GNYLxk.
  10. Please contact your system administrator.
  11. Add correct host key in /c/Users/yesx/.ssh/known_hosts to get rid of this message.
  12. Offending ECDSA key in /c/Users/yesx/.ssh/known_hosts:14
  13. ECDSA host key for [10.8.4.181]:30773 has changed and you have requested strict checking.
  14. Host key verification failed.
  15. Could not read from remote repository.
  16. Please make sure you have the correct access rights
  17. and the repository exists.

排查思路

异常中的关键信息:Host key verification failed.(主机验证失败),并且提示相关的文件是 /c/Users/yesx/.ssh/known_hosts,相应的host key 为 [10.8.4.181]:30773 (注: yesx是主机名)
打开 /c/Users/yesx/.ssh/known_hosts 文件,发现确实有报错信息中的host信息
在这里插入图片描述
查阅了网络资料,这关乎 ssh 协议的一个安全机制。通过ssh连接到计算机时,会缓存计算机的公钥,等到第二次连接上这台计算机时,会验证这台计算机和之前缓存的公钥是否匹配。如果公钥不同,ssh会发出警告或者直接拒绝连接。这样可以避免你受到DNS Hijack之类的攻击。

而我为什么会遇到这种情况?询问运维人员才知道,该地址是docker拉起的gitlab,由于某些原因导致容器重启了(相当于就是服务器重置),所以导致此问题。

解决方案

解决方法简单粗暴,直接根据异常信息,删除 /c/Users/yesx/.ssh/known_hosts 中提示异常的 host key。

reference:
https://blog.csdn.net/ouyang\_peng/article/details/83115290

发表评论

表情:
评论列表 (有 0 条评论,183人围观)

还没有评论,来说两句吧...

相关阅读