Remote Development with SSH in VS Code
- rajababukarmakar
- Jul 23, 2024
- 4 min read
Updated: Nov 24, 2024

The Visual Studio Code (VS Code) is one of the coolest code editor as of 2024. It provides an integrated development environment (IDE) for you to work on multiple platform across your local device and server extensions. The VS Code interface is simple and easy to use, although, knowing a few extra features and useful extensions can help you exponentially and get things done faster, weather it's coding, working on a virtual machine (VM), or just writing.
This article gives you the step-by-step instructions on how to add Remote - SSH on your VS Code and connect to a remote virtual machine anywhere in the world. Once connected to an virtual machine, you can easily interact, read, edit and execute files and folders on the VM. To do this, you don't need to have the source code on your local device. You get most of the features and benefits thorough extensions available freely in the 'extensions' section of your VS Code.

This is a visual representation on how VS Code can be hosted locally to your device and with ease you can access a remote server through extensions to perform all the required tasks. It provides a local-quality development experience with code navigation, completions, debugging, and terminal processes.
Getting started
SSH makes life easy when it comes to remote access and flexibility over the internet. Although, beginner finds it a little difficult to setup SSH at first. We will go through system requirements, installation, managing extensions, SSH client and SSH host setup, and finally connect to a remote host.
System Requirements
Local System:
Supported hardware to install VS Code and OpenSSH compatible SSH client.
Remote Server:
The remote server must be running on x86_64 architecture with a Linux environment on or higher than the mentioned LTS versions (Debian 10+, Ubuntu 20.04+, CentOS / RHEL 8+, Alpine Linux 3.16+)
1GB of RAM and 1 vCPU is mandatory with 2GB of RAM and 2 vCPU is recommended.
Installation
To start with remote-SSH, you need to have a few installations on your local devices from your side:
Install Visual Studio Code.
Install an OpenSSH compatible SSH client. This step is only for those who have no SSH client pre-installed on their Server.
Install the respective extensions on your VS Code: Remote - SSH, Remote - SSH: Editing Configuration Files and Remote Explorer, if not installed otherwise. For ease of installation, you can install one single extension called Remote Development extension pack. It will install all the required extensions along with other server extension, which you may use in future.

This are the required extensions needed to be installed on your VS Code to processed with remote - SSH. To get these, simply search "remote ssh" on the extensions search panel. You can get extensions from the left most panel.
After you get all the extensions in place, then you can see an extra icon on the left most panel of your VS code.

After the installation of the remote - SSH, you get a new icon on the left most panel of your VS Code, called remote explorer. By clicking on this icon you can access your recently added or all of your SSH connections.
In the /remotes/ssh you can access the setting option, from where you can view and edit your created .config file.
Local : SSH files and folder permissions
Folder / File | Permissions |
---|---|
.ssh in your user folder | chmod 700 ~/.ssh |
.ssh/config in your user folder | chmod 600 ~/.ssh/config |
.ssh/id_ed25519.pub in your user folder | chmod 600 ~/.ssh/id_ed25519.pub |
SSH client
Installing a supported SSH client for RHEL / Fedora / CentOS
For respective distribution, kindly check the relevant package manager.
sudo yum install openssh-client
2. Installing a supported SSH client for Debian / Ubuntu
sudo apt-get install openssh-client
Remote host connection
Verifying remote host connection
Before you establish a connection with the server, you can run a command to verify whether you can connect to the SSH host.
ssh user@hostname
// for example 'user' is your user name and host name could be IP or name server, is any.
2. Configuring the .config file
To show all command, press Ctrl + Shift + P. This will open the command search bar. Then enter Remote SSH, to access the "Remote - SSH: Open SSH Configuration File...". In the the configuration file, you get a few option to save the config file. If you want to specify any other configuration file you can do that also.

3. Connect to a SSH Host
To connect a host, you first need to search the command called "Remote SSH". Then select "Remote-SSH: Connect to Host...". This will show all your configured host SSH. To add a new SSH host, you must choose the "Add New SSH Host...".
A new ssh connection command box will be prompted. You need to enter the exact set of command to get your connection request working. Here we are giving a general example what should be in you command.
ssh user@hostName -p xxxx
// p represents the port number.
// xxxx is the port number of the server you are trying to connect.

If the Host holds a password, a prompt to enter the password will appear. Same as the upper image.
Enter the password of the user you are trying to login and let the SSH work on the rest.
This usually the final step while connecting to a SSH Host, if the connection is yet not established, then repeat the step 3, but this time select the server you have configured earlier. Once the connection is established, you can see the secure connection message at the bottom left corner of your VS Code.

After you are connected, a new vs code window will open with the SSH connected message. You can always refer to the Status bar to check which host is connected to. Clicking on it will expand a list of all the remote commands, while you are connected.
You can now access any files available on the connected VM / server. You can use it to read, edit and modify the files while running an application on the VM, or using the computational resources for any other purposes.

Summary
In this article we have explained in details about how to use VS Code to establish a secure connection with a VM / Server using Remote - SSH.
Hope this article help your needs. To learn more on advanced topics related to Virtual Machine or Servers, do follow our blogs.