ssh-add under cygwin

I'm having trouble with ssh-agent under cygwin. The crazy part is that it was working, but stopped after a reboot one day. Here is an example:

sthomas@sthomas-tcg ~
$ keychain ~/.ssh/id_rsa

KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/
Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL

 * Initializing /home/sthomas/.keychain/sthomas-tcg-sh file...
 * Initializing /home/sthomas/.keychain/sthomas-tcg-csh file...
 * Initializing /home/sthomas/.keychain/sthomas-tcg-fish file...
 * Starting ssh-agent
 * Adding 1 ssh key(s)...
Enter passphrase for /home/sthomas/.ssh/id_rsa:
Identity added: /home/sthomas/.ssh/id_rsa (/home/sthomas/.ssh/id_rsa)


sthomas@sthomas-tcg ~
$ ssh-add
Could not open a connection to your authentication agent.

sthomas@sthomas-tcg ~
$ ssh stage
Enter passphrase for key '/home/sthomas/.ssh/id_rsa':

I found this user who is having the exact same problem as me

Issues with ssh-add

Unfortunately I don't have enough rep to comment there. I tried following his instructions but the first step is not working for me:

sthomas@sthomas-tcg ~
$ `eval ssh-agent`
-bash: SSH_AUTH_SOCK=/tmp/ssh-ejseksys5348/agent.5348;: No such file or directory

Anyone know what is going wrong here? The file does exist but the missing filename changes on each execution.

sthomas@sthomas-tcg ~
$ ls /tmp/ssh-ejseksys5348/agent.5348
/tmp/ssh-ejseksys5348/agent.5348

Solution 1:

OK, that other Serverfault.com answer has a typo.

The right thing you want to run is:

eval `ssh-agent`

ssh-agent spits out a bunch of shell statements to set environmental variables. The eval runs them in the current shell. You can invoke ssh-agent that way, or run ssh-agent and then copy-paste its output into your current shell for the same effect.