WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

更换了新的网络环境和 IP 相关后,此次对早期原有项目进行远程 Github 提交的时候抛出了如下异常

Push failed
                @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                @    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/fyhsurvivors/.ssh/known_hosts to get rid of this message.
                Offending RSA key in /Users/fyhsurvivors/.ssh/known_hosts:1
                Host key for github.com 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.

ssh/known_hosts 中的公钥与服务器的不匹配发生了异常错误;

解决办法

首先,通过终端移除本地 ssh 中现有异常的密钥

cd ~/.ssh/
ssh-keygen -R github.com 

其次,打开 known_hosts 添加 
GitHub 的 SSH 密钥指纹 并生成新的密钥

vi ~/.ssh/known_hosts
// 打开编译器后,输入 i
// 添加如下 ssh 密钥条目 
// github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
// 添加完成后 ESC 
// 最后保存退出 :wq

最后,重新尝试链接进行验证即可

ssh -T git@github.com

 

如下是本次的操作 log 可供参考

fyhsurvivors@survivors-deMacBook-Pro OSCEPhone % cd ~/.ssh/
fyhsurvivors@survivors-deMacBook-Pro .ssh % ls
config          id_rsa.pub    id_ed25519      known_hosts     
fyhsurvivors@survivors-deMacBook-Pro .ssh % open known_hosts        
fyhsurvivors@survivors-deMacBook-Pro .ssh % ssh-keygen -R github.com
# Host github.com found: line 1
/Users/fyhsurvivors/.ssh/known_hosts updated.
Original contents retained as /Users/fyhsurvivors/.ssh/known_hosts.old
fyhsurvivors@survivors-deMacBook-Pro .ssh % vi ~/.ssh/known_hosts
fyhsurvivors@survivors-deMacBook-Pro .ssh % open known_hosts        
fyhsurvivors@survivors-deMacBook-Pro .ssh % ssh -T git@github.com
Enter passphrase for key '/Users/fyhsurvivors/.ssh/id_rsa': 
Received disconnect from xxx.xx.xx.x port 22:11: Bye Bye
Disconnected from xxx.xx.xxx.x port 22
fyhsurvivors@survivors-deMacBook-Pro .ssh % ssh -T git@github.com
Enter passphrase for key '/Users/fyhsurvivors/.ssh/id_rsa': 
Hi survivorsfyh! You've successfully authenticated, but GitHub does not provide shell access.
fyhsurvivors@survivors-deMacBook-Pro .ssh % 

重新尝试提交 Git 成功


 以上便是此次分享的全部内容,希望能对大家有所帮助!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值