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:
- Download the prebuilt version of ssh-pageant from github (direct link).
- Upack it and copy the ssh-pageant.exe to your cygwin's /usr/local/bin directory
- 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.
Add this at the end of your .bash_profile
# Setup SSH Agent SSH_ENV="$HOME/.ssh/environment" function start_agent { echo "Initializing new SSH agent..." /usr/local/bin/ssh-pageant | sed 's/^echo/#echo/' > "${SSH_ENV}" echo "succeded" chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null #/usr/bin/ssh-add; } if [ -f "${SSH_ENV}" ]; then . "${SSH_ENV}" > /dev/null ps -ef | grep $SSH_PAGEANT_PID | grep ssh-pageant$ > /dev/null || { start_agent; } else start_agent; fi |
Now you should be able to login using cygwin's ssh.exe with the same comfort of putty.
