push代码时遇到的问题--github-ssh私钥修改

发布时间 2023-03-29 22:17:08作者: 不断寻找

推送代码到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这一行删掉