← All writing

VS Code Remote SSH connection failure problem

This document provides solutions to the problem of "Failed to parse remote port from server output" error when the Remote SSH plug-in in VS Code attempts to connect to a remote server. After a series of investigations and attempts, the author finally found a solution.

阅读中文版 →

Solving the problem of VS Code Remote SSH connection failure

This document provides solutions to the problem of "Failed to parse remote port from server output" error when the Remote SSH plug-in in VS Code attempts to connect to a remote server. After a series of investigations and attempts, the author finally found a solution.

Problem description

When trying to connect to the remote server using the Remote SSH plug-in of VS Code, I encountered the error message "Failed to parse remote port from server output". This error message may be caused by VS Code not correctly parsing the remote port from the output of the SSH server.

Solutions to try

  1. Check SSH configuration file
  2. Updated VS Code and Remote SSH extensions
  3. Manual SSH connection
  4. Check the status of the remote server
  5. Restart VS Code

None of the above common solutions solve the problem.

successful solution

Finally, the author tried to uncheck the VS Code settingsRemote.SSH: Use Local Serveroption and successfully connected to the remote server. When this option is selected (default), VS Code starts a server on the local machine and then connects to the remote SSH server through that local server. When this option is unchecked, VS Code will connect directly to the remote SSH server without going through the local server.

Solution steps

  1. Open VS Code.
  2. Click the gear icon in the activity bar on the left to open settings.
  3. Enter in the settings search boxRemote.SSH: Use Local Server
  4. Uncheck the ones that appearRemote.SSH: Use Local Servercheckbox.

Things to note

Although connecting directly to a remote SSH server can solve some connection problems, it may cause a slight decrease in the performance of VS Code because it does not take advantage of the local server. But as long as you don't encounter performance issues, you don't need to worry too much about this setup.

Conclusion

If you encounter similar problems when using VS Code's Remote SSH plug-in to connect to a remote server, you can also try this method. I hope this solution can help you.