报错信息
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
SHA256:BvXpLFsZagaJlZwOn4hlKheG6r1j+ckNx9JproNhjXw.
Please contact your system administrator.
Add correct host key in //.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /.ssh/known_hosts:2
ECDSA host key for xx.x.x.x has changed and you have requested strict checking.
Host key verification failed.
原因
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地址)