Visual Studio Code remote development with Windows 1027 May 2019 #Windows
Quick notes on getting set up with remote development in Visual Studio code on Windows 10.
Remote development over SSH
First make sure the following commands are executed from
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
choco install which which ssh
Create 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.
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 exit
Transfer public key from Windows 10 onto server
scp ~/.ssh/id_rsa.pub user@server-hostname:~/.ssh/authorized_keys
Note: this will just copy the file onto the server, overwriting an already existing
authorized_keys file if it exists.
id_rsa.pub with your .pub file name, if you named it explicitly.
Test SSH keys
ssh user@server-hostname # should not prompt for password
SSH 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
PROFILEwith a name you will use from a dropdown menu to choose the server later on.
HOSTNAMEwith the server’s hostname or IP address.
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!