"Whenever you can, share. You never know who all will be able to see far away standing upon your shoulders!"
I write mainly on topics related to science and technology.
Sometimes, I create tools and animation.
VS Code is one of the most popular modern IDEs.
One of its very cool features is remote development, that too from Windows host to remote Linux client in a seamless and elegant way!
Below, I'm providing a few simple tweaks to make your experience even more pleasant if you want to develop on a Linux machine remotely from your local Windows.
If you have VS Code running on your Windows machine and you use it for local development, there is no client-server architecture in picture.
But if you want to have your VS Code show code residing on a remote server, you need a VS Code server running remotely (which will be connecting to your local VS Code).
The good news is that VS Code can install its server automatically once you are connected to the remote machine (via VS Code). I've done it on multiple Linux systems, ranging from CentOS to Debian (including Raspberrypi OS), and never had any problem.
Let's see how we do this, and also make some other changes for making our connection automatic.
Note: It's a common practice to call the remote machine client. Just be aware that VS Code will install and run VS Code server on the (remote) client which makes the VS Code on your local machine, the client! Confusing, eh?
Well, it's just a naming thing.
I think, it's partly for avoiding this confusion, on the official page, they just call the local VS Code VS Code (and not VS Code client)!
This is how the
Remote Explorer icon looks that we can see on the left hand side drawer in VS Code - this comes with VS Code.
Remote Explorer needs one of these few extensions to be able to make any connections:
More information about all these extensions can be found on the official page - VS Code Remote Development.
Let's find the Remote - SSH extension in the extensions wizard and install it.
And then go to the
Remote Explorer by clicking on its icon.
I installed all the three extensions mentioned above, hence I see these three entries in the dropdown in the Remote Explorer window as shown below, viz:
Let's click on SSH Targets.
We are now in the
SSH TARGETS window, and we now need to press the
+ icon on the top-right (-ish).
Note that you may need to hover your mouse over this window to make the
+ icon appear.
This gives us the prompt shown below.
At this point you may simply provide the connection command, in the form
Not that this may take some time.
Once this is complete, you get to work on your code that is sitting on the remote (Linux) machine, and you can even run and debug it!
The only slight discomfort with the setup we have done so far is that we'll be prompted for the connection credentials quite often.
I'm not sure but it seems there is an expiry of the connection we get this way.
We'll fix it now.
It becomes slightly tricky at this point as simply clicking on the
+ icon won't give you any other option than entering the credentials in the form of
At the bottom-left, you'll see an icon as shown in green background below - like this:
Click on that, and you'll be presented with a plethora of remote connection options. From these, we need to select Connect to Host... .
This will give us the prompt we intend to see - Select configured SSH host or enter user@host.
What is happening here is that VS Code automatically tries to detect an SSH config file on the host machine, and use the entries from there.
The default location of the SSH config file on Windows is
So, if you have configured this file with, e.g. public key authentication for a specific remote client, VS Code will not only show you that entry, it will also allow you to make a public-key based authentication based connection to the remote client!
You can see in the screenshot below the two entries that I've configured for myself in my SSH config.
Note that it's not a requirement for these pre-configured connections to use public-key authentication. SSH config primarily gives us the option of sugar-coating
user@host command with some customization. Having
publickey authentication is an extra.
You won't be able to make connections using public key until you ensure that a couple of settings/permissions are set as explained below:
.ssh/authorized_keysfile (on remote), and the private key is to be stored somewhere on your host machine.
PuTTYgen, that is good for
PuTTY, but not for the Windows SSH client.
OpenSSHformat which you must exercise.
Private key folder --> Right click --> Properties --> Security --> Advanced --> Disable Inheritance --> Apply* --> Remove System and Administrator (and any other than yourself).
With these settings, your VS Code should be able to make automatic connections to your remote machine.
Note that you'll even be able to install many of the VS Code extensions on the remote machine as well, e.g. the
You'll get to see the option of
install on <remote> while browsing the extensions when connected to a remote host.
While the picture below show a Container box on the right, it works pretty much similarly when you are connecting to a remote machine instead of a container.