DEV Community

loading...

VSCode Remote Connection

Khaled Taymour
Software Engineer | GIS Developer | Geoscientist
・2 min read

In this article I will go through how to connect remotely in VSCode using SSH remote extension.

  • In both local and server: check that you have open SSH installed by searching Manage Optional Features in the Windows start menu.

  • In both local and server: open services.msc and make sure that the services of ssh are running.

  • In Server cmd: run netstat -a | findstr 22 You must see something like this (Listening):
    Alt Text

its default port is 22.

  • From Local cmd: To go to the server run ssh <SERVER_USERNAME>@<SERVER_IP>
    You’ll be asked to enter the server password.

  • In Local cmd: Now I am in a cmd seeing the Server

  • In Remote in C:\Users\<USERNAME>.ssh: run ssh-keygen and name the file of the ssh e.g. testSSH.

  • In Local: Create a config file (with no extension) in C:\Users\<USERNAME>.ssh.

Host <AnyName>
  HostName <IP>
  User <USERNAME>
  IdentityFile ~/.ssh/<name of the ssh file on the server made in previous step (e.g. ~/.ssh/testSSH)>
Enter fullscreen mode Exit fullscreen mode

In VSCode in Local:

  • In Local: Make Sure to install Remote extension by Microsoft.

  • Click on its icon (1)

  • (2) select Remote-SSH: Connect to Host

  • Either do one of the following

  • Choose the just configured SSH Host
    Alt Text

or

  • (3) Enter e.g.: ssh <SERVER-USERNAME>@<SERVER-IP>

  • (4) Choose as below in the image
    Alt Text

  • A new instance of VSCode will be open.

  • You’ll be asked for the Operating System, the Server Password.

  • You’ll find that you’re connected to the Server
    Alt Text

  • You can open terminal in VSCode but firstly make sure that the server has Git downloaded.

  • You are now in the Server terminal:

  • Now you can download plugins and extensions as Live Server on the server from your opened VSCode window.

  • In Local VSCode: File → Open Folder → type your project path on the server.

  • You can run Live Server extension and it will show that it is running on a port e.g. 5501 so now you can browse to http://:5501/ to see live dev.

Thanks for your time, and I am happy to get feedbacks.
Khaled Taymour

Discussion (0)