Warning: the ECDSA host key for 'github.com' differs from the key for the IP address

更新日期: 2023-09-01 阅读次数: 1840 字数: 167 分类: Git

这个问题遇到好多次了,一直懒得解决,但是每次向 github 提交/拉取代码,真的很烦躁,不得不解决一下了。

警告信息

> git pull

Warning: the ECDSA host key for 'github.com' differs from the key for the IP address 'x.x.x.x'
Offending key for IP in ~/.ssh/known_hosts:17
Matching host key in ~/.ssh/known_hosts:26
Are you sure you want to continue connecting (yes/no)?

解决方法

x 部分,替换成对应 IP

> ssh-keygen -R x.x.x.x

# Host x.x.x.x found: line 17
~/.ssh/known_hosts updated.
Original contents retained as ~/.ssh/known_hosts.old

ssh-keygen -R 参数说明

man ssh-keygen

-R hostname | [hostname]:port

Removes all keys belonging to the specified hostname (with optional port number) from a known_hosts file.  This option is useful to delete hashed hosts (see the -H option above).

造成这个问题的原因

This error usually occurs when the host key for GitHub has changed, which can happen for a variety of reasons such as server maintenance or security updates. To fix this, you need to update your known_hosts file with the new host key for GitHub.

参考

  • https://github.com/orgs/community/discussions/54604

微信关注我哦 👍

大象工具微信公众号

我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式