Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VsCode dropping ssh connections frequently with remote server

I'm facing a weird problem after connecting with the remote host using ssh in VSCode, the editor lost the connection after some seconds with the remote server (in this case a droplet in Digital Ocean). But when I open an ssh connection with the remote server using my local terminal instead of my local VSCode of my I do not see the same thing happen, in the terminal the connection keep alive for minutes, as expected.

Perhaps an ssh config on a remote server? I don't think so because using the terminal the problem doesn't occur.

VSCode SSH REMOTE DROPPING CONN AFTER A SOME SECONDS

So, what fix I can apply to my local VSCode configuration to stop this behaviour?

like image 614
Bera Avatar asked Oct 29 '25 04:10

Bera


2 Answers

It was keep happening with my M1 Macbook Pro. The solution was to uncheck useLocalServer setting: "remote.SSH.useLocalServer": false.

This parameter is used to control whether to use a local server for managing SSH connections or not. When it is set to false, VS Code will use the built-in SSH client instead of a local server.

Here's how you can set this configuration:

Inside VS Code, click on the gear icon in the bottom left corner to open the Settings. In the Settings tab, you can either search for remote.SSH.useLocalServer or navigate to "Remote-SSH" settings.

Look for the setting Remote.SSH: Use Local Server and set it to false.

Alternatively, you can directly add this configuration to your settings.json file. Open the command palette (Ctrl+Shift+P or Cmd+Shift+P), type "Preferences: Open Settings (JSON)", and add the following line:

"remote.SSH.useLocalServer": false
like image 162
Elmar Avatar answered Oct 31 '25 02:10

Elmar


https://github.com/susanBuck/e2-fall21/issues/37 seems to address this issue. To summarise:

  • set Remote.SSH: Connect Timeout in the VSC settings to 60

  • set your OpenSSH configuration to:

    HostName your.ip.address
    User root
    ServerAliveInterval 60
    ServerAliveCountMax 10```
    
like image 40
bert bruynooghe Avatar answered Oct 31 '25 01:10

bert bruynooghe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!