Alex Georgiev

Remote Development in Visual Studio Code

Created March 1, 2021

Introduction

If you run multiple servers and you do not want to edit files and open folders using ssh client and text editors like vim, vi or nano and you want to take advantage of all the features of Visual Studio Code then this tutorial is just for you.

There are several extensions that will help you to achieve this. I personally use the Remote Development extension.

remote-plugin.png

I find it really easy to use and it was also quite simple to configure it as well. However, you are free to use other extensions as well. A few examples are the Remote SSH , SSH FS , Remote X11

Prerequisites and System requirements

On your Local machine you need to have a supported OpenSSH compatible SSH client

On the Remote server you need to have an SSH server

Installation

If you already have an openssh-client and Visual Studio installed you can go ahead and install the Remote Development extension package.

Connect to a remote host

I will recommend you using ssh-keys in order to use secure authentication and to make your general experience a lot better.

If you haven't created any ssh-keys yet you can check this tutorial

Checkout our latest product - the ultimate tailwindcss page creator 🚀

First, you can verify that you can access the server using an ssh-client and also make sure that your ssh-keys are copied to the remote server as well. Once you can confirm that the connection from the ssh-client is working you can go ahead and open Visual Studio Code.

remote-connect.png

**Note: You need to replace the $USER with your actual username for the server and the remote-server with the server's hostname or the IP address.

To open the configuration file open the palette and select Remote-SSH Open Configuration File...

conf-pallette.png

Then select the SSH config file - path_to_user/.ssh/config

The file will look like this:

ssh-config.png

Note: You need to replace the user, hostname, path to the identity file and specify any custom SSH port, if you're using the default SSH port 22 you do not need to specify the port in the SSH configuration file.

If you're experiencing issues you will see the log for the SSH authentication in the Output console at the bottom of your Visual Studio Code, you can examine the log and locate any problems. The most common will be the pubkey authentication failure - Permission denied (publickey)

If this is the error you can see in the log then open the SSH configuration file ssh-config.png and make sure that the details you see are correct. The path to the Identity file for users using Windows will be: C:\Users\User\.ssh\id_rsa1 windows-config.png

Conclusion

This is pretty much how you can connect to a remote server via Visual Studio. I find it really handy because in this way you can take advantage of all VS features and installed extensions for coding faster, better and etc. I hope you find this post helpful and please comment if you use other plugin or use a different method to code on a remote server.

Used sources

You can also check the process on Visual Studio's website and also explore some additional features.