How do I Connect to My Linode Instance with VSCode via SSH?

Linode Staff

I've been using VSCode as the IDE for all of my coding projects. I was looking through some of the popular extensions and saw one for remote SSH. Can I use this to connect to my Linode compute instance via SSH?

4 Replies

Yes! You can use VSCode to connect directly to a Linode instance via SSH. I'll explain how.

Setup and Secure Your Instance

Since you've been using VSCode, I'm going to assume you have it installed on your local system so we'll move directly into making sure your Linode instance is setup securely. We suggest adding a limited user account, creating an SSH key pair, and disabling root logins. Instructions for this can be found in our Setup and Secure Guide.

Once you've got your SSH configurations working correctly, you can move on to setting up VSCode.

VSCode Configurations

The first thing you want to do is install the Remote - SSH VSCode extension. This will allow you to connect to your remote instance.

Once installation is complete, click the "><" button in the bottom left corner of your VSCode window to bring up the option to make a remote connection. Click Connect to Host… -> Configure SSH Hosts… then select your .ssh/config file. Add your connection information to this file.

Host <your-instance-name>
    HostName 192.0.2.17
    User <your-limited-username>
    IdentityFile ~/path/to/ssh/key
    ServerAliveInterval 60
    ServerAliveCountMax 10

You'll want to make sure the HostName is your instance's IP address and that the path used for the Identity File points to the SSH key used for secure login to the instance, usually in the .ssh directory.

I've set a couple of different timeout configurations which you can keep out take out. The important info is your Host, HostName, and User.

Save the file and close it.

Connect to Linode Instance

Now that you've added your configurations to your config file, you're ready to connect to your Linode instance. Click the "><" once again and select "Connect to Host…". You should see the name you input as the Host for your instance listed there. Select it to start the connection via SSH.

It will take a bit of time because VSCode will need to set some things up on the host side. Once it's done though, you will have a fully accessible VSCode environment available on your server for easier remote development work!

@tlambert

By HostName <your.instance.ip.address>

Do you mean x.x.x.x? x.x.x.x:xx? root@x.x.x.x? root@x.x.x.x:xx?

By IdentityFile /path/to/ssh/key

Do I use Linux or Windows format? ~/.ssh/id_ras or C:\Users\Me\ .ssh\id_rsa ? And is that the correct file in the .ssh directory?

I feel like I've tried all these combinations, but an example of what it should look like would be awesome.

@letarogers - Thanks for the feedback! The HostName is your instance's IP address and the IdenityFile will be the path to your SSH key which is generally found in the .ssh directory. It will usually look like this:

IdentityFile ~/.ssh/id_rsa.pub

I added these changes to the original post. Let me know if you have any other questions!

Thank you, and I hope others find the clarifications useful. I did some more searching early this morning and finally got this to work:

Host myLinode
HostName 1.2.3.4
User myUser
Port 1234
IdentityFile ~/ .ssh/id_rsa
ServerAliveInterval 60
ServerAliveCountMax 10

I also had to fix the permissions on the config file on my Win 11 computer.

What I have been finding over the last ten years of working with the backend and frontend of my headless ubuntu installation and jQuery/Bootstrap, etc. web site is that a lot of the documentation assumes that the audience are primarily computer programmers and developers who know a lot of the unwritten stuff. But there are many of us who are in the sciences who follow tutorials and Google why things aren't working. Cheers!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct