using ssh-agent in cygwin

Wayne Davison wayne@opencoder.net
Tue Jul 20 03:53:52 GMT 2021


On Mon, Jul 19, 2021 at 12:44 PM Jesse Thompson wrote:
> *TL:DR;* I'm looking for options to reliably start and manage an ssh-agent
> daemon in Cygwin.

I recommend the "keychain" package, which is available in Cygwin.
You'd add something like the following to your shell initialization
scripts:

/usr/bin/keychain -q $HOME/.ssh/*_?sa
source $HOME/.keychain/$HOSTNAME-sh

This ensures that you get prompted for your key password on first
login, which unlocks all the key-file args when keychain adds them to
the ssh-agent that it starts for you. Any subsequent shells just share
the existing ssh-agent.

If you don't like that the password prompt happens at login time, you
could leave off the list of default key files and add them using
ssh-add later on.  I sometimes go this route and use a ~/bin/ssh shell
script that looks like this:

#!/bin/bash
case `ssh-add -l` in
*2048*|*1024*) ;;
*) ssh-add ~/.ssh/*_?sa ;;
esac
exec /usr/bin/ssh "${@}"

This method asks you for your key password the first time you run ssh.

..wayne..


More information about the Cygwin mailing list