Joy*_*Joy 33 git ssh github ssh-keys
我不知道发生了什么,但有一天,当我起床时,git push我的改变发生了:
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.112.4'\nOffending key for IP in /Users/joyliu/.ssh/known_hosts:13\nMatching host key in /Users/joyliu/.ssh/known_hosts:16\nRun Code Online (Sandbox Code Playgroud)\n我似乎无法连接到 Github。我用 Google 搜索了修复并sed -i '13d' ~/.ssh/known_hosts删除了第 13 行,但随后它显示了相同的错误,但行号不同。
我这样做的时候也发生过这种情况git pull。
谁能帮我?先感谢您!
\n========更新========
\nssh-keygen -R github.com在和之后ssh-keyscan github.com >> ~/.ssh/known_hosts,它仍然无法正常工作......它给出了:
(base) \xe2\x9e\x9c liuzz10.github.io git:(master) ssh-keygen -R github.com\n# Host github.com found: line 17\n# Host github.com found: line 18\n# Host github.com found: line 19\n# Host github.com found: line 20\n/Users/joyliu/.ssh/known_hosts updated.\nOriginal contents retained as /Users/joyliu/.ssh/known_hosts.old\n(base) \xe2\x9e\x9c liuzz10.github.io git:(master) ssh-keyscan github.com >> ~/.ssh/known_hosts\n# github.com:22 SSH-2.0-babeld-4b034cc8\n# github.com:22 SSH-2.0-babeld-4b034cc8\n# github.com:22 SSH-2.0-babeld-4b034cc8\n(base) \xe2\x9e\x9c liuzz10.github.io git:(master) git pull\nWarning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.112.4'\nOffending key for IP in /Users/joyliu/.ssh/known_hosts:13\nMatching host key in /Users/joyliu/.ssh/known_hosts:18\nAre you sure you want to continue connecting (yes/no)? yes\nfatal: refusing to merge unrelated histories\n(base) \xe2\x9e\x9c liuzz10.github.io git:(master) git push\nWarning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.112.4'\nOffending key for IP in /Users/joyliu/.ssh/known_hosts:13\nMatching host key in /Users/joyliu/.ssh/known_hosts:18\nAre you sure you want to continue connecting (yes/no)? yes\nTo github.com:liuzz10/liuzz10.github.io.git\n ! [rejected] master -> master (non-fast-forward)\nerror: failed to push some refs to 'github.com:liuzz10/liuzz10.github.io.git'\nhint: Updates were rejected because the tip of your current branch is behind\nhint: its remote counterpart. Integrate the remote changes (e.g.\nhint: 'git pull ...') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\nRun Code Online (Sandbox Code Playgroud)\n
小智 32
如果您收到以下错误:
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address 'IP_ADDRESS'
Run Code Online (Sandbox Code Playgroud)
我建议执行以下操作:
$ ssh-keygen -R github.com
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,则从已知主机中删除 IP 本身:
$ ssh-keygen -R IP_ADDRESS
Run Code Online (Sandbox Code Playgroud)
这应该可以解决你的问题。
phd*_*phd 21
[回答有关 SSH 主机密钥的问题。]
您有 2 个不同的主机github.com密钥~/.ssh/known_hosts。该警告是关于第一个警告的。删除两个键:
ssh-keygen -R github.com
Run Code Online (Sandbox Code Playgroud)
并重新添加正确的密钥:
ssh-keyscan github.com >> ~/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)
这将添加当前的 RSA 和 ECDSA 密钥。
这是最近在 github 在 2023 年 3 月 24 日大约 05:00 UTC 轮换其RSA SSH 主机密钥后开始的。几乎每个人都开始看到同样的问题。要按照参考帖子的建议删除警告,请运行以下命令
ssh-keygen -R github.com
Run Code Online (Sandbox Code Playgroud)
或者您可以更新~/.ssh/known_hosts文件以手动删除该条目。
要自动将密钥添加到您的已知主机并永久删除 github.com 的警告,请运行以下命令
curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12593 次 |
| 最近记录: |