Connecting Visual Studio Code to Server via SSH

Use visual Studio Code instead of Nano. Connect the code editor to its remote server via SSH in just a few steps.

Connecting Visual Studio Code to Server via SSH-heroimage

CAUTION

Please note that initially, I wrote this blog post in German. This translation is for your convenience. Although every effort has been made to ensure accuracy, there may be translation errors. I apologize for any discrepancies or misunderstandings resulting from the translation. I am grateful for any corrections in the comments or via mail.

The problem with the terminal

The โ€œnormalโ€ way to connect to one is via SSH. The easiest way to do this is with a terminal (Link to the Microsoft Terminal).

SSH via terminal

Suppose this is not possible (of course, with the IP address of your own server). In that case, you must check whether SSH is installed on the server and the device you want to establish the connection with.

In Windows, we look for the menu for โ€œoptional featuresโ€ and open it.

Windows Start menu

Optional features

Here is the OpenSSH client

If the OpenSSH client does not appear in the list, it must be added (not to be confused with the OpenSSH server, which should be installed on the server).

Uninstall from Internet Explorer

At this point, I took the opportunity to say goodbye to Internet Explorer ๐Ÿ˜ƒ

There is not much to see as soon as you have logged in to the server.

Empty shell

The folders can be displayed with ls. But this way you can only see the folders or files in the directory you are currently in.

Listing of directories

Of course, programs such as tree can also display an overview of all folders and subfolders if you install it beforehand via apt install tree. At the latest when you want to edit files, however, it becomes cumbersome again.

cd docker
nano docker-compose.yml

Nano Text-Editor

Alternatively also vim docker-compose.yml

Vim text editor

You can exit Vim again by typing :q.

With larger files I lose the overview in these text editors.

VSCode as a solution

It is also possible to establish an SSH connection to the server via VS Code recently. The prerequisite for this is that the program is installed on the computer. In contrast to Visual Studio (without code), this is a free program from Microsoft.

Visual Studio Code](https://code.visualstudio.com/) is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

When you start Visual Studio Code, it looks relatively unspectacular.

VSCode Dashboard

Using the extensions ( Ctrl + Shift + X ) we search for the extension remote ssh and install it. Press F1 or Ctrl + Shift + P to open the command line. We search for SSH and select โ€œRemote-SSH: Connect to Host โ€ฆโ€ Remote SSH

Enter username@ip-address in the field that pops up. A new VSCode window opens with a query about whether Linux, MacOS or Windows is on the server. Linux should be the correct answer in most cases. You will then be asked for the password.

Now we press Open folder in Explorer and select โ€œ/home/username/โ€ in the new field.

Open folder

You will then be asked for the password again. Once you have entered it, you will see the serverโ€™s folder structure.

Folder structure

It is then also possible to create and edit your own files in a more beautiful and, in particular, feature-rich editor.

VSCode Editor

However, you should be careful as it is easier to accidentally delete your files.


This website uses cookies. These are necessary for the functionality of the website. You can find more information in the privacy policy