Git服务器报错:host key for (ip地址) has changed and you have requested strict checking

一:报错提示

如下:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
85:82:b1:58:20:21:a5:da:be:24:e8:14:9a:12:b2:d2.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:2
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R xxx.xxx.xxx.xxx (服务器ip地址)
ECDSA host key for xxx.xxx.xxx.xxx (服务器ip地址) has changed and you have requested strict checking.
Host key verification failed.
fatal: The remote end hung up unexpectedly

二:原因

ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告。

原因是我的GitLab服务器重装了系统(清除了与我本地SSH连接协议相关信息),本地的SSH协议信息便失效了。SSH连接相同的ip地址时因有连接记录直接使用失效的协议信息去验证该ip服务器,所以会报错,使用上述命令便可以清除known_hosts里旧缓存文件。

三:解决方法

删除xxx.xxx.xxx.xxx (服务器ip地址)的相关rsa的信息即可

在本地机输入一下命令行:

ssh-keygen -R xxx.xxx.xxx.xxx (服务器ip地址)

 

接着git拉取代码,成功


版权声明:本文为W_317原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
THE END
< <上一篇
下一篇>>