In this tutorial we’ll integrate SSH into VS Code in a way that won’t require entering a password every time.
If you’re on Windows, you will need to install the OpenSSH feature from Settings or you can use WSL to be able to use
You can generate an SSH key using
ssh-keygen -t ed25519. Press enter on the prompt to use the default filename.
Keep track of where the key is stored. (e.g.
This will be useful when configuring the Remote-SSH VSCode extension.
During the process of adding our keys, we’ll have to enter our passwords.
ssh-copy-id -i path/to/file/if/not/default USER@HOST # examples ssh-copy-id -i .ssh/id_ed25519.pub USER@HOST ssh-copy-id -i /mnt/c/Users/maste/.ssh/id_ed25519.pub USER@HOST
When doing this, press enter to any yes/no prompts such as fingerprints and etc. The fingerprint prompt is important only if you can’t trust your network (e.g. Starbucks WiFi).
If you’re having trouble with this, just
cd into the
.ssh folder and use
If you’re on Windows, you won’t have access to
ssh-copy-id. Instead you can modify the first command below or use the second command
if you aren’t doing anything abnormal on your computer.
type path\to\id_algo.pub | ssh USER@HOST "cat >> .ssh/authorized_keys" # type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh user@host "cat >> .ssh/authorized_keys" # the above is a helper that hopefully requires no modifications
Install the Remote - SSH extension
Use the Command Palette (Ctrl + Shift + P) and use the “Remote-SSH: Open SSH Configuration File…” command
Select the first path (e.g.
Enter the information for your remote server(s). Here is mine for reference. I had to comment out PreferredAuthentications.
Host uWaterloo User e5lopez HostName linux.student.cs.uwaterloo.ca IdentityFile "C:\Users\maste\.ssh\id_ed25519" # Linux/MacOS: IdentityFile "/Users/USER/.ssh/id_ed25519" # PreferredAuthentications publickey
From the command palette, use “Remote-SSH: Connect Current Window to Host…” and select the host you just added
A window will show up asking you to choose the platform for the remote server so choose the remote server’s platform (e.g. Linux)
If all goes well, you should be able to connect without having to enter a password
Tip: add multiple folders in the remote server to a workspace