With ‘pageant’, the popular SSH client PuTTY provides a convenient tool for using SSH keys as authentication method. After loading all desired SSH keys into pageant, PuTTY is able to use those keys automatically for further authentication attempts.
Besides PuTTY itself, other applications are able to use pagent. Some programs like WinSCP and FileZilla provide pageant support out of the box, in some other cases, support for pageant needs to get added separately.
When I’m running Windows, I use MSYS2 as my development environment of choice. Contrary to WSL (at least if we don’t want to use cross compilation), it’s easily possible to compile native Win32 binaries with GCC while preservice the ‘look and feel’ of a standard ‘Linux shell’.
From time to time, it’s neat to be able to use SSH, scp or rsync from within a MSYS2 session. It would be even better if we could use the SSH keys that are loaded into pageant anyways for this.
First, we have to install the package that’s responsible for the communication with pageant in the MSYS2 shell:
pacman -S msys/ssh-pageant-git
In order to automatically enable ssh-pagent when launching MSYS2, the following lines need to get added to the file
.bashrc (or the equivalent file of any other shell in case bash isn’t used):
# Set up ssh-agent eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
After restarting MSYS2, the pageant-based authentication becomes available. Compared to a Linux system, the shell behaves exactly like if the private key would have been added with the
ssh-add command to the OpenSSH key agent.