← Other topics

SSH Remote development with VSCode

Video Notes

To remotely work on a server in VSCode via SSH start by installing the extension Remote - SSH by Microsoft:

Configure new connection

Once the extension is installed, click the remote connection button on the bottom left of your VSCode window:

Remote connection icon in VSCode’s Remote SSH Extension

In the command palette that pops up, choose Connect to host...:

Connect to host dialog in VSCode’s Remote SSH Extension

Then choose Configure SSH Hosts:

Configure SSH hosts in VSCode’s Remote SSH Extension

Select the first config file it lists. For example, my SSH config file is located at /Users/Susan/.ssh/config:

Select SSH config file in VSCode’s Remote SSH Extension

In your SSH config file, we’re going to add connection information for the server you want to connect to. Here is what that connection information should look like:

Host my-server
    HostName your.server.ip.address
    User root
  • Update my-server to be some alias for this connection.
  • Update your-server-ip-address to match the IP address of the server you’re connecting to.
  • Update root to whatever user you connect to this server as.

After adding these lines, save your changes.



Let’s now connect to the server we just configured.

Click the connection icon (bottom left of VSCode window) again. In the command palette that pops up, choose Connect Current Window to Host... and choose the host you just added:

Connect Current Window to Host

This should establish a new remote connection with your server.

Note that anything you do in this window will now occur on your server.

You can tell when a VSCode window is connected to the server by the remote development button/icon on the bottom left of the screen:

Install extensions on server

Not all the VSCode extensions you’ve installed locally will be automatically be available when connected to your server; you’ll need to install them there.

To do this, open your Extensions and find any extensions that are greyed out and choose Install in SSH.

Installing extensions on server

I suggest only installing extensions you really need/use, as an excessive amount of extensions can slow down the remote development process.

Connection issues?

If you’re working on a budget server with not a lot of RAM, you might run into issues where the connection frequently stalls while using the Remote SSH plugin.

Symptoms include repeatedly seeing the dialog Disconnected. Attempting to reconnect...

Stuck on Setting up SSH Host Initializing VSCode when using SSH Remote Development extension

Or being stuck on the notification Setting up SSH Host [...] Initializing VSCode

Disconnected. Attempting to reconnect... dialog in VSCode when using the Remote Development SSH extensions

If this happens to you, see my guide: VSCode Remote SSH Keeps disconnecting.

← Other topics