一:報錯提示
如下:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ ? ?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拉取代碼,成功