git报“REMOTE HOST IDENTIFICATION HAS CHANGED”错误

问题描述:

本地进行git pull时发现报错,具体报错信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

1
ssh-keygen -l -f ~/.ssh/known_hosts

ssh-keygen -R 服务器端的ip地址(上面warnning提示中对应序号的ip地址)

出现提示:

 

 此时 重新进行git pull操作,出现提示:

 

 输入yes,会自动更新known_hosts。

然后就可以正常进行git操作了。

 

posted @   Morango  阅读(644)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
*{cursor: url(https://files-cdn.cnblogs.com/files/morango/fish-cursor.ico),auto;}
点击右上角即可分享
微信分享提示