问题描述:
本地进行git pull时发现报错,具体报错信息如下:
Pushing to github.com:xxxxxxxx.git @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Please contact your system administrator. Add correct host key in /xxxxxxxxx/.ssh/known_hosts to get rid of this message. Offending RSA key in /xxxxxxxxx/.ssh/known_hosts:1 Host key for github.com 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.
问题原因:
经排查,是github服务器升级,导致客服端known_hosts过期。原因如下: 第一次使用SSH连接时,会生成一个认证,储存在客户端的known_hosts中,远程git服务器更新时,本地known_hosts过期。
SSH会把每个曾经访问过的Git服务器的公钥记录在/Users/xx/.ssh/known_hosts文件中,当下次访问时会核对公钥,如果和上次的记录不同,SSH就会发出警告。
解决办法:
把本地缓存的 hosts 删除就好了,具体操作如下:
进入到对应的.ssh目录下,查看known_hosts
ssh-keygen -l -f ~/.ssh/known_hosts
ssh-keygen -R 服务器端的ip地址(上面warnning提示中对应序号的ip地址)
出现提示:
此时 重新进行git pull操作,出现提示:
输入yes,会自动更新known_hosts。
然后就可以正常进行git操作了。
标签:git,REMOTE,CHANGED,hosts,ssh,key,known From: https://www.cnblogs.com/morango/p/17269515.html