ssh链接报错:IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY

一、问题描述

SSH链接git上传代码,之前一直可以,但是当前报错:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
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:****....jQXVUpKZIDTMczCvj3tD2s. Please contact your system administrator. Add correct host key in /c/Users/...02/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/...02/.ssh/known_hosts:1 RSA 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.

二、问题原因

用OpenSSH的时候会将每个你访问过计算机的公钥(public key)都记录在/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,信息报错类似错误,如当前情况。

所以当前就是git的的公钥有变化,正如报错信息上写的。

ssh链接报错:IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY_第1张图片

三、解决方法

如下步骤

1.第一步:观察报错信息,定位是.ssh/known_hosts 文件的第几行出现的问题。

如当前报错指定第1行,github.com相关的。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-x2QYX9HY-1679996766172)(tmp.assets/image-20230328174011727.png)]

2.第二步:删除.ssh/known_hosts的指定行,保留其他信息

ssh链接报错:IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY_第2张图片

删除后保存,然后重新传输到git,成功。

3.注意建议操作前备份

建议提前先备份一下信息,免得到操作失误,还是可以恢复。

你可能感兴趣的:(ssh,git,github)