今日VSCode在连接linux服务器时,报错错误:
1)问题现象:
连接remote-ssh服务器时,提示如下错误:
[09:50:27.277] "install" terminal command done [09:50:27.278] Install terminal quit with output: Host key verification failed. [09:50:27.278] Received install output: Host key verification failed. [09:50:27.278] Failed to parse remote port from server output [09:50:27.279] Resolver error: Error: at Function.Create (c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:429193) at Object.t.handleInstallOutput (c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:427836) at Object.t.tryInstall (c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:521609) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:485262 at async Object.t.withShowDetailsEvent (c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:488612) at async Object.t.resolve (c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:486341) at async c:\Users\PC\.vscode\extensions\ms-vscode-remote.remote-ssh-0.66.0\out\extension.js:1:559963 [09:50:27.284] ------
2)解决:
①通过chatGPT搜索得知,可能是KnowHost文件有问题,具体回答如下:
It seems like you are having trouble connecting to a remote server using the Remote-SSH extension in Visual Studio Code. The error message “Host key verification failed” suggests that there is a problem with the SSH host key verification process. This can happen if the remote server’s host key has changed, or if there is a problem with the known_hosts file on your local machine.
One possible solution to this issue is to remove the entry for the remote server from your known_hosts file. This file is typically located in the .ssh directory in your user’s home directory. You can open this file in a text editor and remove the line that corresponds to the remote server you are trying to connect to. After saving the changes, try connecting to the remote server again.
If this does not solve the issue, you may want to check the SSH configuration on both your local machine and the remote server to ensure that everything is set up correctly. You can also try using a different SSH client to connect to the remote server to see if the issue is specific to Visual Studio Code or if it is a more general problem with your SSH setup. I hope this helps! Let me know if you have any further questions. 😊
②打开knowhost文件
清空以上内容,重新连接,即可正常进行连接.
3)原因
之前添加过相同IP的服务器,遗留的密钥串与新的服务器密钥串不一致,才会导致这样的问题.