具体报错如下:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 ED25519 key sent by the remote host is
SHA256:x5db23ieVmhXqvwXNXQ96w5iSpioY1g5OhSp1duS3B4.
Please contact your system administrator.
Add correct host key in /Users/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/.ssh/known_hosts:61
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
报错原因
根据这个回答,原因是:
在2023年3月24日,GitHub 更新了用于保护 GitHub.com 的 Git 操作的 RSA SSH 主机密钥,因为私钥在公共 GitHub 存储库中短暂暴露。如果在那个日期之前记住了SSH客户机中 GitHub 之前的密钥指纹,那么就会有这个警告。
但是我应该是3月份之后才更新了一波ssh,不知道为什么还是有警告...
解决方法
- 删除本地这个文件中记住的github的密钥
ssh-keygen -R github.com
- 尝试推送代码
git pull然后如下:
在输入yes之后需要输入
git@github.com的密码,尝试输入github账号的密码,发现不行...
- 根据这篇文章,输入以下命令:
ssh -T -p 443 git@ssh.github.com
然后修改ssh的配置文件,添加上以下内容:
Host github.com
Hostname ssh.github.com
Port 443
User git
- 再次尝试连接github
ssh -T git@github.com
这样就可以了,执行
git push就可以成功推送代码了