Update 2: With newer version it is much easier to just follow the instructions here.

On windows I mostly use Putty as my SSH client. But in some cases for example when I use unison or rsync I use the ssh client from cygwin.

Following good practice I use public key authentication and Putty’s Pageant to manage my password protected keys. This works great with Putty and Plink. I thought this would be great if I could use the same agent for cygwin too. As often the solution already existed in the form of ssh-pageant.

Here is a small tutorial how to set it up:

  1. Download the prebuilt version of ssh-pageant from github (direct link).
  2. Upack it and copy the ssh-pageant.exe to your cygwin’s /usr/local/bin directory
  3. You need to edit your .bash_profile file in order to start the ssh-pageant on opening a shell

The method I use is different form the one described in ssh-pageant’s readme as it only starts one instance of ssh-pageant and reuses this in subsequent sessions. It is based on the Github Help about ssh keys.

Update: In never versions the –reuse makes things a lot easier. (Thanks sun for pointing this out)

Add this at the end of your .bashrc

# ssh-pageant
# Cygwin maps /tmp to c:\cygwin\tmp
# MinGW maps /tmp to %TEMP% (%LocalAppData%\Temp)
# Both consume $TEMP (user-specific) from the Windows environment though.
eval $(/usr/local/bin/ssh-pageant -ra $TEMP/.ssh-pageant)

See https://github.com/cuviper/ssh-pageant/pull/19

Now you should be able to login using cygwin’s ssh.exe with the same comfort of putty.