推送代码到github时遇到:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
xxxxxxxxxx
Please contact your system administrator.
Add correct host key in /c/Users/xxx/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/xxx/.ssh/known_hosts:7
RSA host key for [ssh.github.com]:443 has changed and you have requested strict checking.
Host key verification failed.
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
是因为GitHub更新了用于保护 GitHub.com 的 Git 操作的 RSA SSH 主机密钥,也就是使用ssh和远程连接的主机推送时都会遇到这个问题,
- 详见 https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/
- 而在执行以下命令时遇到了写入失败的问题。
$ curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts
解决方法之一:将~/.ssh/known_hosts
文件里的ssh.github.com
这一行删掉 - 其他问题详见: https://stackoverflow.com/questions/75830783/warning-remote-host-identification-has-changed-did-github-change-their-rsa