文章内容

2023/4/17 14:16:01,作 者: 黄兵

"Host Key Verification Failed" when connecting to remote repository

今天远程克隆 github 项目库,出现了如下提示:

Host key verification failed.

fatal: Could not read from remote repository.

由于忘记截图,这里只说一下出现问题的原因。

出现问题的原因:

我们在使用 ssh 经行远程克隆代码的时候,使用 SSH,每个主机都有一个密钥。客户端会记住与特定地址关联的主机密钥,并在主机密钥出现更改时拒绝连接。这可以防止中间人攻击。

github 的主机密钥 github.com 已更改。如果这对您来说没有问题 ${HOME}/.ssh/known_hosts,我们需要通过编辑删除行 github.com 或让 SSH 实用程序为您执行此操作,从本地缓存中删除旧密钥。

解决方案:

我们执行如下命令:

ssh-keygen -R github.com

如果在 Windows 系统中提示:未找到 ssh-keygen,我们可以找到文件 c:\user\{username}\.ssh 文件,手动编辑:


删除对应的行之后保存,再次克隆,就不会出现如上错误了。


参考资料:

1、Git error: "Host Key Verification Failed" when connecting to remote repository


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - "Host Key Verification Failed" when connecting to remote repository

分享到:

发表评论

评论列表