Remote Ssh Visual Studio Code



When working on a development project in the tech field, you often interact with remote servers. I ofen used to face difficulties in moving files and connecting to remote servers on Windows or Mac OS then I came across Visual Studio Code Remote - SSH. In this post I will show you how to connect to a remote server using SSH with Vscode and move files easily between your local computer and the remote server.

Visual

VSCode Version: 1.38.1 OS Version: Windows 10 I try to connect to linux machine using the ssh extention using a local tunnel and sshkey the tunnel is working if I use a putty with the same key and tunnel the connection works Steps to Rep. Ubuntu ssh visual-studio-code vscode-settings vscode-remote. How to save a file in vscode-remote SSH with a non-root user privileges. Save with “Retry as Sudo” using keyboard commands. Save files on remote SSH server with sudo privileges on VS Code.

  1. Okay, now that we got that out of the way onto the topic of Remote editing files over SSH with Visual Studio Code (VSCode for short) - I am a recent convert, to Visual Studio Code from Sublime.
  2. Remote development over SSH This tutorial walks you through creating and connecting to a virtual machine (VM) on Azure using the Visual Studio Code Remote - SSH extension. You'll create a Node.js Express web app to show how you can edit and debug on a remote machine with VS Code just like you could if the source code was local.

Content:

From Vscode docs:

The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code’s feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem.

Source: Vscode docs.

I have created an instance on my univeristy’s (unimelb) cloud platform as illustrated in the figure below. I will be using the test instance for today where we will connect to the instance using vscode remote ssh. I have setup the instance with my public ssh key.

Note:You can use any cloud platform as the basics would be the same. You would need your public key on the remote server (under authorized keys)

SSH with Vscode

At this stage, I assume you have an instance you want to connect and your public key resides on the server gaining you acess to it. Now using vscode to connect to the server can be done in 3 simple steps as shown below.

Step 1: Install extension

You have to first install the vscode extension for remote-ssh. You can do so by search for ssh in the extensions and installing the extension as shown below.

Step 2: Add host to ssh config

Once the extension has been installed an icon will be pop up on the left side menu where you can establish a new connection to a remote server (host) as shown below.

Now click on add new host and enter the ssh command for connecting to the remote server and pointing to your ssh key. Choose the config file you want to add the host to.

Remote

Vscode Setup Remote Ssh

Step 3: Connect to host

The remote server (host) should be added to the list. In order to connect you can right-click and choose from the options based on you preference.

Done! you can now connect your remote server and use its terminal in vscode.

Moving files

One of the great features of this extension is not requiring the use of another tool to move files between the remote server and your local machine.

Uploading files to remote server

Uploading files to remote servers can be easily done by simply dragging files to the vscode ui (under ssh) as shown below.

Visual Studio Code Remote Ssh Permission Denied

Downloading files from remote server

Downloading files from remote servers can be easily done too by simply right-clicking and choosing download from the vscode ui as shown below.

You can check out additional features from the docs (link here).

Remote Ssh Visual Studio Code

Happy remote coding!