VS Code Remote SSH editing
A nice feature is available in VS Code : Remote SSH editing.
This is a convenient way to edit your files remotely from VS Code just with a SSH connection.
Installing this feature can be tricky on windows because of the SSH client. This part is not well documented and this story helps you to install everything from scratch.
Setup
- Install VS Code insider : https://code.visualstudio.com/insiders/
- Install putty & puttygen : https://www.putty.org/
- Install cygwin and select openssh package : https://www.cygwin.com/
SSH Configuration
- Convert your private key to openssh format with puttygen and save it to
C:\Users\username\.ssh
folder
- Create a SSH config file in your default ssh directory :
C:\Users\username\.ssh\config
with the following content :
Host your_host_name.your_domain
User ec2-user
HostName your_host_name.your_domain
IdentityFile C:\Users\username\your_key.ssh
Test your SSH connection
Open a cygwin console and test your SSH configuration :
ssh -F /cygdrive/c/Users/your_username/.ssh/config your_host_name.your_domain_name
If it working got to next step to configure VS Code
VS Code configuration
Open VS Code and type :
Ctrl+P > Remote-SSH:Connect to Host
A drop-down menu should open and you can select your SSH configuration :
A new VS Code should open and from that window open a new SSH terminal :
And type code-insiders .
where .
it the directory you want to edit in VSCode.
And the magic appears .. you are editing your server side files remotely with your favorite editor.
Happy remote coding !