vscode无法远程连接服务器,但是xshell可以远程连接
报错信息:
[10:33:37.611] Running script with connection command: "D:\Program Files (x86)\Git\usr\bin\ssh.exe" -T -D 50825 "ipxxxx" bash
[10:33:37.614] Terminal shell path: C:\Windows\System32\cmd.exe
[10:33:37.843] > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> ]0;C:\Windows\System32\cmd.exe
[10:33:37.843] Got some output, clearing connection timeout
[10:33:37.863] > @ 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:JRZtxxxxxx2rLqcYyZaM0atT3NJ4.
> Please contact your system administrator.
> Add correct host key in /c/Users/xxxx7/.ssh/known_hosts to get rid of this
> message.
> Offending ECDSA key in /c/Users/xxxx7/.ssh/known_hosts:6
> Host key for ipxxxx has changed and you have requested strict checking.
> Host key verification failed.
> 过程试图写入的管道不存在。
出错原因:
根据输出信息,发现是由于远程主机的密钥发生了变化,导致 VS Code 无法连接。可以尝试更新本地known_hosts文件中的主机密钥,以便重新建立信任关系。
解决方案:
1、打开 Git Bash 或者 PuTTY 等 SSH 客户端,进入用户目录下的 .ssh 文件夹:
cd ~/.ssh
2、执行以下命令,删除 known_hosts 文件中与远程主机 IP 地址对应的行:
ssh-keygen -R
其中,指的是远程主机的 IP 地址。再次连接远程主机,此时会重新生成并添加新的主机密钥到 known_hosts 文件中。
重新连接,成功!