HOW TO CONNECT YOUR REMOTE SERVER TO VSCODE (Linux Server) Finally..

Seif Elredeini
2 min readDec 25, 2023

--

Connecting to your remote server for faster access to files and easier management could be one of the reasons that you want to connect to your remote server via vscode.

Here are the requirements:

  1. HostName (public ip address of your server).
  2. User (the username of your machine).
  3. IdentityFile (the private key to your server).

→ On Ubuntu your username will be “ubuntu” by default.

→ On Cents OS your username will be “opc” by default.

Now here comes the tricky part, it worked on my machine the same way i am going to describe now. Hopefully it works on your machine too without any problem.

First thing to do is to download the Remote — SSH extension from the vscode Marketplace, here is a screenshot(Install First One):

  • Now Open a new window and click F1. Write ssh and open the configuration file to edit it. (you can customize your own conf file so it’s not the default one if you want)

Here is screenshot (The file will look similar to this one at the end):-)

Follow these main Steps:

  1. Open your config file and add these (copy paste them, then edit them)
Host put_the_name_you_want_here
HostName ip_address
User ubuntu
IdentityFile ~\.ssh\privatehavefun.pem

2. It will look like this

Host NewYorkServer
HostName 55.162.26.13
User ubuntu
IdentityFile ~\.ssh\privatehavefun.pem

MOST IMPORTANT PART:

Now focus on the next part. The whole thing depend on the IdentityFile and how to deal with it.

Now you need to go to your C:/ Drive → Users → your_username → .ssh

the .ssh folder might be hidden so you have to open SHOW HIDDEN FILES option.

So, where ever you keep your private key file at, you are going to take it and put it in the .ssh Folder and its better to make it .pem extension, you can use puttygen to convert it, if you have the key as .ppk extension. Then add it in front of the “IdentityFile”. (~\.ssh\) is important, TAKE CARE.

IdentityFile ~\.ssh\your-private-key.pem

Done. Hopefully you solved your problem, i tried to make it as simple as possible.

--

--