Putty keys inside of MSYS2

I’m working a lot on Windows systems. Fortunately, these days it is extremely easy to use most UNIX development tools & environments within Windows as well. Two tools I use a lot are Putty and MSYS2.

For a long time, I had separate private keys for putty and for msys2. This was purely because I never found time to figure out how I could make the keys loaded in putty (through pagent.exe) available to the msys2 environment. A fewy days ago, I finally found myself desperate enough to start investigating this issue.

It turns out that it’s super easy to achieve as somebody already occupied him or herself with this task: Enter cuviper’s ssh-pagent scripts. ssh-pageant works like ssh-agent, except that it leaves the key storage to PuTTY’s Pageant. It sets up an authentication socket and prints the environment variables, which allows OpenSSH connections to use it.

Things get even easier: There’s a ready-to-go package for MSYS2 that can be installed out of the box:

pacman -S ssh-pageant

After installation, add the following to your ~/.bashrc or ~/.bash_profile:

# ssh-pageant
eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")

And that’s it!

Be sure to reference the official documentation in case information in this blog post becomes outdated in the future.

comments powered by Disqus