github提示:Host key verification failed. fatal: Could not read from remote repository

在使用github仓库拉取代码时,有时候会出现RSA密钥的指纹对不上的情况,执行git pull等操作时出现类似以下提示:

[root@test1]# git pull
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
d5:2c:63:d9:bc:75:9d:de:b1:4e:36:28:9f:7a:9c:39.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending RSA key in /root/.ssh/known_hosts:1
RSA 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.

大致意思就是RSA密钥的指纹对不上,或者是仓库没有权限,在排除权限问题后,需要扫描一下github.com使用的指纹,并添加到~/.ssh/known_hosts中,执行:

[root@test1]# ssh-keyscan -H github.com >> ~/.ssh/known_hosts 
# github.com SSH-2.0-babeld-077acb5b
# github.com SSH-2.0-babeld-077acb5b
[root@test1]# git pull
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '20.205.243.166'
Offending key for IP in /root/.ssh/known_hosts:6
Matching host key in /root/.ssh/known_hosts:7
Are you sure you want to continue connecting (yes/no)? yes
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (4/4), done.
Unpacking objects: 100% (13/13), done.
...

可以看到后面的git pull操作已经可以正常执行了。

github提示:Host key verification failed. fatal: Could not read from remote repository

原文链接:https://beltxman.com/3902.html,若无特殊说明本站内容为 行星带 原创,未经同意禁止转载。

发表评论

您的电子邮箱地址不会被公开。

Scroll to top