Reputation: 3055
When you're running VS Code Remote SSH and loose network connectivity over a long period of time and return to VS Code, the status on the bottom left show's "Disconnected from SSH: ". However, there doesn't seem to be a way to reconnect the session. I always have to revert to starting a new VS Code Remote SSH session. How can I reconnect?
Upvotes: 81
Views: 59730
Reputation: 360
Not sure if this is a newer feature since the OP, but I just click on the lower left corner where it has the SSH connection listed. That brings up some options in the Command Palette at the top. I always choose "Remote-SSH: Connect Current Window to Host" so it doesn't open a new VS Code window. I see there is a comment under the OP that zitrax couldn't get that to work, but maybe they have other issues.
Upvotes: 1
Reputation: 1
You can use tmux, and set tmux as the default terminal profile.
Upvotes: -3
Reputation: 5090
In line with @PaulOmta answer, the easiest way is now adding this Reload button extension! It adds a Reload button to your status bar on the bottom right.
I found that ⌘-R shortcut didn't work on mine (maybe because I have other keybinders on)
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=natqe.reload
Upvotes: 4
Reputation: 2163
You can reload the window. It keeps unsaved changes even. Press F1 to search for commands, then search for:
Developer: Reload Window
Version of VSCode when trying this: 1.53.2.
Upvotes: 121
Reputation: 2752
EDIT: This does NOT work to reestablish the connection. It only helps to keep it alive. Thanks for the comments. I misinterpreted the question while looking for something similar for myself.
I'll leave the answer just in case it helps someone else.
You need to set a custom ssh file and add parameters to keep the connection to your host alive :
Host SomeRemoteHost
HostName MyRemoteHostName
User MyUsername
ServerAliveInterval 60
ServerAliveCountMax 30
Go to the SSH extension settings and set the new custom ssh config file path. This won't work if your machine goes into sleep mode, but it will keep the connection alive in the background while you work on other things.
PS: Make sure your ssh settings are correct for the host or you won't be able to log in.
Upvotes: 9
Reputation: 42
It seems that there is something that drops your idle connection. As I know SSH doesn't have any configuration for dropping an idle connection but firewalls has. there might be some sort of firewall or monitoring software or hardware device which drops your connection. if you are using Linux OS the following command might help you:
ssh -o "ServerAliveInterval 60" <SERVER_ADDRESS>
this command sends keep alive request to ssh every 60 seconds.
Upvotes: 0