Basically, how to set this up.
Remote development over SSH
First make sure the following commands are executed from C:\System32\OpenSSH: ssh, ssh-keygen, scp. If they are located in e.g. Chocolatey’s bin folder, keys will be searched for in weird places. This can be verifed by installing which:
choco install which
which sshCreate key pair in Windows 10 client
cd ~
mkdir .ssh
cd ssh
ssh-keygen -t rsa -b 4096- RSA is the recommended authentication security.
- The -b flag instructs
ssh-keygento increase the number of bits used to generate the key pair, and is suggested for additional security.
Prepare server
I am using a CentOS 7 server.
ssh user@server-hostname
mkdir -p ~/.ssh
touch ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
exitTransfer public key from Windows 10 onto server
scp ~/.ssh/id_rsa.pub user@server-hostname:~/.ssh/authorized_keysNote: this will just copy the file onto the server, overwriting an already existing authorized_keys file if it exists.
Replace id_rsa.pub with your .pub file name, if you named it explicitly.
Test SSH keys
ssh user@server-hostname # should not prompt for passwordSSH config in Windows 10
If you haven’t already, install the “Remote development” extension in vscode.
Click the lower left >< icon in vscode and choose “Remote-SSH: Open configuration file…”. Then enter something like:
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host PROFILE
HostName HOSTNAME
User USERNAME- Replace
PROFILEwith a name you will use from a dropdown menu to choose the server later on. - Replace
HOSTNAMEwith the server’s hostname or IP address. - Replace
USERNAMEwith the username used to log in over SSH.
More options are outlined in the docs.
Connect to server over SSH and code away
Click the lower left >< icon in vscode and choose “Remote-SSH: Connect to Host…”. Choose your newly created profile.
A new vscode session will launch, and from the “Open folder” dialog, choose your project’s folder. Voila!