PuTTY is a common choice for an SSH client on Windows. Despite this, most manuals for setting up integration with tools like Git and VS Code seem to focus on OpenSSH. So what do I do when I have my SSH public/private keys set up in PuTTY, and want to reuse those instead of setting up separate keys for the OpenSSH client that ships with Git on Windows?
This guide is written for PuTTY as that's probably what most people use, but
I've personally used it with KiTTY. The only difference there is some of the
file names change (
klink.exe, for example).
The full PuTTY toolbox includes Plink, "a command-line connection tool similar to UNIX ssh". Git has an option core.sshCommand to select an alternative command for SSH connections. That makes this a very simple affair:
At this point you may want to test cloning a repository over SSH to make sure it works.
With the "Remote - SSH" extension, Visual Studio Code can open folders and files on a remote host over SSH. Again, Plink can be provided as an alternative SSH client. Because of how the extension tries to verify it's a real OpenSSH client, this requires a little futzing:
Create a file
ssh.bat with the following contents:
1 2 3
In VS Code, find the option
remote.SSH.path and set it to the full path to
VS Code stores its SSH configuration in a configuration file in the format used
by the OpenSSH client. It then passes the
Host field to the SSH client, which
- if it were OpenSSH - would read the SSH client config file and load settings
from there. PuTTY and Plink don't understand that, but Plink does support using
PuTTY session names:
- Configure your host in PuTTY (say, hostname
dominic, session name
- Create a new remote SSH host in VS Code. For the SSH command, just enter
- Connect to the new remote host through VS Code to test it.
This was tested with KiTTY 0.76.1.2, Visual Studio Code 1.74.2, and Remote - SSH 0.94.0.