How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (2023)


Visual Studio Code is a popular Integrated Developer Environment (IDE) for developers. Its large selection of plugins, minimal design, and cross-platform support make it a great choice for developers of all levels. This tutorial focuses on using the Remote-SSH plugin to enable remote software development. With this plugin you can edit files on your local workstation, but run development tasks such as program execution, unit tests, or static analysis on a remote server.

There are many reasons why this may be beneficial to you. For example, you may have a Windows workstation and want to develop on Windows, but your code will eventually run on Linux. You may need more RAM or processing power than your current machine has available, or you want to keep code off of your personal machine due to a company policy, or the desire to keep your workstation prestine.

In this tutorial, you’ll enable the Remote-SSH plugin, configure Visual Studio Code to execute code on the remote server, and execute code from your local Visual Studio Code installation on the remote server.


In order to follow along with this guide, you’ll need:

  • A local development machine running Windows, MacOSX, or Linux. This tutorial will not work on ChromeOS devices.
  • Visual Studio Code, which you can download and install from the official web site.
  • An SSH key pair generated:
    • If you’re using macOS or Linux, you can follow Step 1 from How to Set Up SSH Keys on Ubuntu 20.04. The commands are the same, so don’t worry that the tutorial says it is for Ubuntu 18.04.
    • If you’re using Windows, follow the tutorial How to Create SSH Keys with PuTTY on Windows to create your SSH Key.
    • If you’re using DigitalOcean, you can follow the How to Upload SSH Public Keys to a DigitalOcean Account guide.
  • One Ubuntu 18.04 server set up by following the Ubuntu 18.04 initial server setup guide, including a non-root sudo-enabled user and a firewall.

Step 1 — Installing the Remote-SSH Plugin

The Extensions Marketplace is where you can download supported and third-party extensions for a variety of different tools and programming languages. This is where you will search for the Remote-SSH plugin and install it.

On the left-hand side of the IDE there is a vertical row of five icons. The bottom icon, which looks like four squares in a box with the top right square exploding out, is the icon for the Extensions Marketplace:

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (1)

You can also access this section by pressing Ctrl+Shift+X. When you open this page you will see suggested plugins to download and install.

Once you have the Extensions Marketplace open, type Remote-SSH in the Search Extensions in Marketplace search bar. When you find the plugin, select it and then click the green Install button to install the extension.

(Video) Using Visual Studio Code for Remote Development

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (2)

The extension is now installed. Next, you’ll configure the extension so you can connect to your server.

Step 2 — Configuring the Remote-SSH Plugin and Connecting To Your Server

Now that you have the plugin installed you can configure it to connect to a server. To do so, you’ll need the following pieces of information:

  • The server’s IP or hostname.
  • The username you’ll connect with.
  • The private key you’ll use to authenticate your user.

You’ll use this information to create an SSH configuration file that Visual Studio Code can use to SSH to the server to sync files and execute code on your behalf. You will create this configuration using Visual Studio Code.

Now that you have the Remote-SSH plugin installed, you’ll see a small green box in the bottom left-hand corner of the Visual Studio Code interface. If you hover over the box with your mouse pointer, the popup will say Open a remote window. The button looks like a greater than sign slightly under a less than sign ><, like the one in the following image:

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (3)

Click the button, and a dialog box appears in the top center. Select Remote-SSH: Open Configuration File… from the list:

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (4)

The next prompt will ask you which configuration file you want to open. If you’re on Windows, you’ll see two locations: one in your personal user directory, and one in the installation location for SSH. You should use the file in your user directory when configuring the server.

(Video) Visual Studio Code Remote Development through SSH

Select the file and your editor will open the config file. Add the following code to the file to define the connection to your server, replacing the highlighted sections with the information for your server:


Host my_remote_server HostName your_server_ip_or_hostname User sammy IdentityFile /location/of/your/private/key

Here’s how this configuration file works:

  • Host: This specifies a name for your host. This lets you use a short name or abbreviation instead of the full IP address or host name when connecting to the server.
  • HostName: The actual hostname of the server, which is either an IP address or a fully qualified domain name.
  • User: The user you want to use to connect with.
  • IdentityFile: The path to your SSH private key. On Mac and Linux systems, you’ll find this in your home directory in a hidden .ssh directory, typically called id_rsa. If you are on Windows you will have specified a location to save this file when you created it using putty-gen.

Specify the appropriate values in your file and save the file.

Visual Studio Code is now configured and ready to connect to your server. Click on the green Open a remote window button in the bottom left-hand corner and select Remote-SSH: Connect to Host…

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (5)

Once you’ve done this all the availble and configured servers will appear in the dropdown menu. Select the server that you want to connect to from this list.

If this is the first time you have connected to this server from your machine, you’ll likely be prompted with the SSH Fingerprint verification dialog, like the one in the following image:

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (6)

(Video) Remote Development with VSCode (SSH)

This is to ensure that you are really connecting to the server you think you are. You can verify this by logging in to your server manually and running ssh-keygen -l -f /etc/ssh/ to view the fingerprint of the server. If this fingerprint is the same as the one being presented to you in Visual Studio Code, then you are indeed connecting to the server you think you are so you can click Continue.

Visual Studio Code defaults to opening a new window when a new connection is made. A new window will appear with the welcome screen. You’ll know that your connection was successful if you see SSH: your_ip_address_or_hostname in the green box in the bottom left-hand corner. This means that Visual Studio Code is connected and communicating with your remote server.

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (7)

Now that you’re connected, you can run commands and code from your editor.

Step 3 — Executing Code on the Remote Server

The Remote-SSH plugin is configured, and it’s time to run some code on your remote machine. Open a terminal window by selecting Terminal from the navigation bar at the top of the Visual Studio window and clicking New Terminal. You can also open a terminal by pressing CTRL+Shift+`. The terminal that is opened is a terminal on your remote server, not one on your local machine.

When the terminal opens, issue the following command to view the IP address of your server to verify that you are connected to your remote server:

  1. ip addr

You’ll see the following output in your terminal:


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 16:cb:05:5b:30:f1 brd ff:ff:ff:ff:ff:ff inet your_server_ip brd your_broadcast_address scope global eth0 valid_lft forever preferred_lft forever ...

To test out the ability to run remote code, create a new Python file called in your editor. When you are connected to your remote server, all files created through Visual Studio Code will be saved to that server, not on your local machine.

(Video) Remote Development with Visual Studio Code

Add the following contents to the file:

print("Hello Sammy!")

To run this program on your server, open a terminal in Visual Studio Code from the navigation menu or by pressing the key sequence CTRL+Shift+`. Since this terminal session is connected to your remote server, run the following command in the terminal to execute your program:

  1. python3

Your program’s output will be displayed.

How To Use Visual Studio Code for Remote Development via the Remote-SSH Plugin | DigitalOcean (8)

You can also execute the file from the Debug context menu by selecting Run without Debugging.

Note: If you have any development extensions installed in Visual Studio Code, like the Python extension, you will have to reinstall these extensions on your server through the Extension Marketplace. If you have previously installed these plugins in Visual Studio Code, when you search for them again, the Marketplace will say Install on SSH: hostname. Always pay attention to what devlopment context you are in, because this is where Visual Studio Code will install your plugins and create your files. If you try to run your code without these plugins installed, error dialog boxes will appear in the bottom right-hand corner of the screen prompting you to install them on your remote server. After you have installed these they will likely require you to reload Visual Studio Code. When you relaunch it, it will continue working on the remote server without you having to manually reconnect.


You now have Visual Studio Code configured for development on a remote server using SSH. Remote execution with an IDE provides many benefits, including the ability to quickly test how your code runs on different operating systems and different hardware specifications. As long as you have an internet connection you could connect to your server and work on your code from any computer, and you’ll be able to develop using a Linux environment even if you run Windows as your primary operating system.


How do I SSH into Visual Studio Code? ›

Connect to a remote host

In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P) and use the same user@hostname as in step 1. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.

How do I connect to a remote server using Visual Studio? ›

Set up the remote connection
  1. In Visual Studio, choose Tools > Options on the menu bar to open the Options dialog. ...
  2. In the Connection Manager dialog, choose the Add button to add a new connection. ...
  3. Enter the following information: ...
  4. Choose the Connect button to attempt a connection to the remote computer.
17 Oct 2022

How do I access my VS Code remotely? ›

Remote tutorials

The tutorials below will walk you through running Visual Studio Code with the Remote Development extensions. Connect to remote and virtual machines with Visual Studio Code via SSH. Run Visual Studio Code in Windows Subsystem for Linux. Run Visual Studio Code in a Docker Container.

How do I connect to a remote server using SSH? ›

To initiate an SSH connection to a remote system, you need the Internet Protocol (IP) address or hostname of the remote server and a valid username. You can connect using a password or a private and public key pair. Because passwords and usernames can be brute-forced, it's recommended to use SSH keys.

How do you configure Visual Studio code to remote SSH to an AWS instance? ›

Obtain your AWS Credentials and SSH Key
  1. You can find your AWS credentials under AWS Details of your AWS Academy account.
  2. Download the SSH key (labsuser.pem) file to your local computer. ...
  3. Open up Visual Studio Code.
  4. Click on the Open a Remote Window icon at the bottom left-hand corner of the window.
  5. Select Connect to Host.
13 Mar 2022

How do I call a Visual Studio code from terminal? ›

Launching from the command line

You can also run VS Code from the terminal by typing 'code' after adding it to the path: Launch VS Code. Open the Command Palette (Cmd+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.

Can you SSH with Visual Studio? ›

You can connect over SSH into another machine from Visual Studio Code and interact with files and folders anywhere on that remote filesystem. If you have an app located on a different computer, you could use SSH to connect to it and access your app, view its files, and even modify, run, and debug it.

How do I run a script on a remote server? ›

To run a script on one or many remote computers, use the FilePath parameter of the Invoke-Command cmdlet. The script must be on or accessible to your local computer. The results are returned to your local computer.

How do I setup a remote server connection? ›

Remote Desktop to Your Server From a Local Windows Computer
  1. Click the Start button.
  2. Click Run...
  3. Type “mstsc” and press the Enter key.
  4. Next to Computer: type in the IP address of your server.
  5. Click Connect.
  6. If all goes well, you will see the Windows login prompt.
13 Dec 2019

Can I use Visual Studio Code without Internet? ›

You can install extensions manually without an internet connection using the Extensions: Install from VSIX... command, but if you use the extension panel or devcontainer. json to install extensions, your local machine and VS Code Server will need outbound HTTPS (port 443) access to:

How do I connect devices in VS Code? ›

🔌 ADB Interface for VSCode
  1. First connect your device trough USB.
  2. Run ADB:📱 Disconnect from any devices.
  3. And run ADB:📱 Reset connected devices port to :5555.
  4. And Then ADB:📱 Connect to device IP enter your device (settings > status > ip address) IP address and be fine.
2 Mar 2019

How do I connect my VS Code to AWS? ›

Connect to AWS through the Toolkit for VS Code
  1. Open VS Code.
  2. To open the Command Palette, on the menu bar, choose View, Command Palette. ...
  3. Search for AWS and choose AWS Toolkit Connect to AWS.
  4. Choose a profile from the list. ...
  5. Open the AWS Toolkit Explorer Side Bar, which we call the AWS Explorer, to verify the connection.

How does SSH remote work? ›

SSH encrypts and authenticates all connections. SSH provides IT and information security (infosec) professionals with a secure mechanism to manage SSH clients remotely. Rather than requiring password authentication to initialize a connection between an SSH client and server, SSH authenticates the devices themselves.

What is SSH remote command? ›

SSH Remote Command allows a connection with a SSH server to be established and that shell scripts to be executed. Take a look at the configuration parameters of the component: Account: for the component to make an authentication to a SFTP server, it's necessary to use a BASIC or PRIVATE-KEY-type account.

How do I enable SSH connections? ›

  1. Connect to the server via SSH.
  2. Escalate privileges to 'root': ...
  3. Set password for 'root' user: ...
  4. Make sure that the configuration file /etc/ssh/sshd_config has parameters PermitRootLogin and PasswordAuthentication are set to yes and not prepended by # symbol.
29 Sept 2022

Can I use Visual Studio with AWS? ›

The AWS Toolkit for Visual Studio conveniently includes the AWS SDK for . NET, so you can get started building . NET applications on AWS infrastructure services in Visual Studio, including Amazon S3, Amazon EC2, AWS Elastic Beanstalk, and Amazon DynamoDB.

How do I connect to an EC2 instance via SSH? ›

Connect to your EC2 Instance
  1. Open your terminal and change directory with command cd, where you downloaded your pem file. ...
  2. Type the SSH command with this structure: ssh -i file.pem username@ip-address. ...
  3. After pressing enter, a question will prompt to add the host to your known_hosts file. ...
  4. And that's it!

Which software is used to connect via SSH to the AWS instance? ›

EC2 Instance Connect provides a simple and secure way to connect to your EC2 instances using one-time SSH keys.

Does Visual Studio code have a console? ›

Select Run > Step Into or press F11 . Visual Studio Code runs the Console.

How do I call a Visual Studio code from terminal in Linux? ›

Launching VS Code from the terminal looks cool. To do this, press CMD + SHIFT + P, type shell command and select Install code command in path. Afterwards, navigate to any project from the terminal and type code . from the directory to launch the project using VS Code.

Can you SSH into a virtual machine? ›

If you want direct access to the virtual machines in your service instance, set up an SSH client so that you can run commands from your local machine. Download and install an SSH client on your local machine. Find the VM IP address and private key.

Can I run SSH command on Windows? ›

You can start an SSH session in your command prompt by executing ssh user@machine and you will be prompted to enter your password. You can create a Windows Terminal profile that does this on startup by adding the commandline setting to a profile in your settings.

How do I connect to SSH from Windows? ›

  1. Open a Command prompt window on your technician PC.
  2. Connect to the device: To connect using a username and password: cmd Copy. ssh user@192. 168. ...
  3. Enter the password for your user if you're connecting with a username and password, or if you configured your key to require a password.
24 Jun 2021

How do I run a local script on remote server using SSH? ›

The Solution: Pass The Script Over Standard Input

The bash -s command means “execute the following commands in a new bash session.” The -s flag makes it read from standard input, and the < bit will read a local script file into standard input.

How do I run automation scripts on a remote computer? ›

Set DCOM Configuration Properties on the Remote Computer
  1. On the computer where you want to run the automation script, select Start > Run. ...
  2. Enter dcomcnfg and click OK. ...
  3. Select QuickTest Professional Automation from the DCOM Config list and open the Properties dialog box for the application.

How do I SSH into a shell script? ›

How to use SSHPASS inside the Shell Script ( A Secure Approach )
  1. Gets UserName and Password from the User.
  2. Read the list of server names from a file.
  3. Create a Script on the Runtime named using HereDocument.
  4. Copy the Created TestScript to the remote server using SCP.
19 Jun 2022

What tools do you use to connect to a remote server? ›

10 Best Remote Access Software (Remote Control Software) In 2022
  1. Comparison of Top Remote Access Tools.
  2. #1) NinjaOne (Formerly NinjaRMM)
  3. #2) SolarWinds Dameware Remote Support.
  4. #3) Atera.
  5. #4) Supremo.
  6. #5) ManageEngine Remote Access Plus.
  7. #6) RemotePC.
  8. #7) TeamViewer.
16 Nov 2022

How do I connect to a remote server in terminal? ›

In the Terminal app on your Mac, choose Shell > New Remote Connection. Select a protocol in the Service list. Select a shared server in the Server list. In the User field, enter a user name, then click Connect.

How can I access my computer remotely? ›

Important: Make sure you're using the latest version of the Chrome Remote Desktop app.
  1. On your Android phone or tablet, open the Chrome Remote Desktop app. . ...
  2. Tap the computer you want to access from the list. If a computer is dimmed, it's offline or unavailable.
  3. You can control the computer in two different modes.

What's the difference between VS Code and Visual Studio? ›

Visual Studio vs Visual Studio Code - Differences

Visual Studio is an Integrated Development Environment, also known as an IDE. Visual Studio Code is a code editor. A developer can easily edit their code. VS is slower when it comes to performing across different platforms.

What is the best alternative to Visual Studio Code? ›

Top 10 Visual Studio Code Alternatives & Competitors
  • Notepad++
  • Sublime Text.
  • UltraEdit.
  • Atom.
  • Brackets.
  • GNU Emacs.
  • CodePen.
  • BBEdit.

Do I need a compiler for VS Code? ›

Install a compiler

VS Code is first and foremost an editor, and relies on command-line tools to do much of the development workflow. The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer.

How do I add plugins to VS Code? ›

You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.

How do I share my VS Code project? ›

If you select Start Collaboration session from the Session Details menu, an invitation link to your session will automatically be copied to your clipboard. You can share this link with anyone you'd like to collaborate with, as long as they also have VS Code and the Live Share Extension Pack downloaded.

How do I run code in VS Code Live share? ›

Press CTRL+SHIFT+P in VSCode to open the command palette, as shown below. Enter Start Collaboration Session and select liveshare. start from the list. Click OK when you get a pop-up message to accept unblocking ports on your firewall.

How install AWS CLI in VS Code? ›

Install the Toolkit for VS Code
  1. Start the VS Code editor.
  2. In the Activity Bar on the side of the VS Code editor, choose the Extensions icon. ...
  3. In the search box for Extensions, search for AWS Toolkit. ...
  4. In the right pane, choose Install.

What is AWS Toolkit for VS Code? ›

The AWS Toolkit for Visual Studio Code is an open source plug-in for the Visual Studio Code that makes it easier to create, debug, and deploy applications on Amazon Web Services.

What is difference between SSH and SSH? ›

The main difference is that sshd is a server (like a web server serving https) and SSH is a client (think of a web browser). The client/user authenticates itself against the server using the users credentials.

How does SSH works step by step? ›

SSH consists of three distinct layers: The transport layer establishes safe and secure communication between a client and a server during and after authentication. It oversees data encryption, decryption, and integrity protection. Furthermore, it helps speed up data exchange by providing data compression and caching.

Is remote SSH safe? ›

SSH is a widely-used protocol used for accessing Linux servers securely. Most users use SSH connections with default settings to connect to a remote server. However, the unsecured default configurations also pose various security risks. The root account of a server with open SSH access may be at risk.

What is SSH key and how do you use it? ›

The SSH key pair is used to authenticate the identity of a user or process that wants to access a remote system using the SSH protocol. The public key is used by both the user and the remote server to encrypt messages. On the remote server side, it is saved in a file that contains a list of all authorized public keys.

What is SSH agent used for? ›

The ssh-agent is a helper program that keeps track of user's identity keys and their passphrases. The agent can then use the keys to log into other servers without having the user type in a password or passphrase again. This implements a form of single sign-on (SSO).

How do I check if SSH port is enabled? ›

To check current port number being used by SSH, run the command below:
  1. $ grep -i port /etc/ssh/sshd_config.
  2. $ sudo nano /etc/ssh/sshd_config.
  3. $ ssh -p <port_number> <username>@<ip_address>

How do I know if SSH is enabled? ›

Step 1: Check if SSH is enabled

To check if SSH is enabled on your system, open a command prompt and end the command ssh . If it provides you with help for using SSH, it is already enabled! You should be able to follow the Linux instructions using the ssh-keygen command from the command prompt.

How do I enable SSH? ›

Activate the SSH server
  1. sudo rm -f /etc/ssh/sshd_not_to_be_run sudo systemctl enable ssh sudo systemctl start ssh.
  2. sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf sudo start ssh.
  3. sudo systemctl stop ssh sudo systemctl disable ssh.
  4. sudo stop ssh sudo mv /etc/init/ssh.conf /etc/init/ssh.conf.back.
3 Feb 2022

How do I start Visual Studio from Linux command line? ›

Visual Studio Code also includes a command prompt (terminal) window and you can open one or more of them with: Ctrl + ` on your keyboard.
  1. Download Visual Studio Code for Linux.
  2. Make a new folder and extract VSCode-linux-x64. zip inside that folder.
  3. Double click on Code to run Visual Studio Code.
30 Apr 2015

How do I run a SSH command in Windows? ›

You can start an SSH session in your command prompt by executing ssh user@machine and you will be prompted to enter your password. You can create a Windows Terminal profile that does this on startup by adding the commandline setting to a profile in your settings.

Can we run Linux commands in Visual Studio Code? ›

You can use the store app, or search for a Linux distro in the Windows search bar. Choose the Linux distribution you want to install (for example Ubuntu) and follow the prompts. Select Install. And when done, select Launch to get started.

Can you use Visual Studio Code on Linux? ›

VS Code runs on macOS, Linux, and Windows.

Is there Visual Studio Code for Linux? ›

VS Code is a free code editor, which runs on the macOS, Linux, and Windows operating systems. Follow the platform-specific guides below: macOS.


1. Remote Development using VsCode || VsCode remote Ssh || Write Code on server directly
(Stack Beast)
2. Use Visual Studio Code for remote development (Remote SSH)
3. Visual Studio Code Remote - SSH
(Visual Studio Code)
4. Setup SSH in VS Code to access your server easily
5. Visual Studio Code: Remote Dev with SSH, VMs, and WSL | Tabs vs Spaces
(Microsoft Developer)
6. Open remote servers in VSCode natively!
Top Articles
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated: 09/15/2022

Views: 5981

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.