背景:需要往 github 推送代码时抛出了以下错误日志

liudui@MacBookM1Pro go % git push ssh master 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /Users/liudui/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/liudui/.ssh/known_hosts:6
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

原因八九不离十大概率是客户端 known_hosts 保存的认证过期了,平时通过 ssh 连接到服务器之后服务器销毁再创建同样会出现了这样的问题,见怪不怪。

修复方法,编辑 known_hosts 将保存的 github.com 记录删除,push 之后会重新生成

vim /Users/liudui/.ssh/known_hosts

测试

liudui@MacBookM1Pro go % git push ssh master
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Enter passphrase for key '/Users/liudui/.ssh/id_rsa': 
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 668 bytes | 668.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:xichengliudui/gojenkins.git
   780c0dd..3bc648b  master -> master
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐