I use ssh a lot also on Windows for example to connect to Github or connect to Linux servers in the cloud and elsewhere. Many of these systems require an ssh_key and this can cause issues on Windows. VSCode for example has no means to let me enter the ssh passphrase so git pull/push fails.
The solution for this is to use an ssh agent. I had set up the putty peagent long time ago and actually didn’t remember the details when a colleague asked me how to do it. While trying to figure out how the config looked like and what I had on my system I came across this stack overflow response and realised that with the inclusion of OpenSSH in Windows 10 things have become way easier. Also I like using tools natively included rather than separate software.
Just in case the answer on stack overflow disappears here the steps in brief:
- check if the service called “OpenSSH Authentication Agent” is running. By default it seems to be disabled so enable it and start it.
- add the private key to ssh agent by running e.g. by running in powershell
ssh-add ~\.ssh\privatekey
. It will ask you for the passphrase once.
This is enough to use it for ssh connections.
For the use case of using git with ssh you will also need to set the environment variable GIT_SSH
which tells git where to find the ssh binary. You want to make sure it points to the correct one, in our case the one from OpenSSH. In a default installation it is located at C:\Windows\System32\OpenSSH
but it’s worth checking in a DOS commandline with where ssh
. Set the variable to the response and you should be good to go.