VScode突然无法连接远程服务器(WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED)

前言

昨天还好好的,今天突然就连接不上远程服务器了, 以为是远程ssh配置有有问题,但是神奇的是使用Xshell是可以访问的,上网查了半天, 终于解决了,现在记录一下吧。

输出日志

[21:25:49.335] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:25:52.814] > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> ]0;C:\WINDOWS\System32\cmd.exe
[21:25:52.814] Got some output, clearing connection timeout
[21:25:52.838] > @    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:d54uHzyHldsazO/nu0GKnnNkcL+xAiGPFJIlLNNU7A.
> Please contact your system administrator.
> Add correct host key in C:\\Users\\XuHR/.ssh/known_hosts to get rid of this message.
> Offending RSA key in C:\\Users\\XuHR/.ssh/known_hosts:20
> RSA host key for [192.168.1.0]:80 has changed and you have requested strict check
> ing.
> Host key verification failed.
> ssh_exchange_identification: Connection closed by remote host

无用的方法

首先查到一种方法是先使用Xshell登陆远程服务器,然后在远程服务器的home路径下删除 .vscode-server文件夹:

ll -a ~/
rm -rf ~/.vscode-server

然后重新连接,很遗憾,无法连接。。。。。

有用的方法

在本地的home路径,找到.ssh文件夹,里面有个known_hosts,然后使用记事本打开,找到你要连接的远程服务器ip地址,把属于它的内容全部删了,再重新连接即可。
其实谜底就在谜面上,输出日志上也提示了。

> Add correct host key in C:\\Users\\XuHR/.ssh/known_hosts to get rid of this message.
> Offending RSA key in C:\\Users\\XuHR/.ssh/known_hosts:20

你可能感兴趣的:(疑难杂症,vscode,ssh)