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
  • Hmm. Can you do export SSH_AUTH_SOCK=/tmp/ssh-ejseksys5348/agent.5348 and then do the ssh-add? – cjc Apr 25 '12 at 16:24
  • @cjc wouldn't that only be a temporary fix? – Tim Apr 25 '12 at 16:29
  • Simple question, but is the ssh-agent process running? – mgorven Apr 25 '12 at 17:01
  • @mgorven The OP's post suggests it's running, since he ran the command and there's a resulting socket file. The problem is to get ssh-agent's environmental variables exported so that ssh can see them. – cjc Apr 25 '12 at 17:11
  • @cjc Based on "the missing filename changes on each execution" I suspected that the process wasn't hanging around, but now I see that ssh-agent doesn't handle an existing running agent nicely and so this is expected. – mgorven Apr 25 '12 at 17:17

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.

| improve this answer | |

fixed another aspect of this message : I imported a key from a mint VM to cygwin. I used nano without nowrap and copied my public key over 3 lines instead of 1. I had to put in on an unique line and it finaly worked with eval.

| improve this answer | |
  • I'm confused. Are you commenting on an answer on a completely different question? – Katherine Villyard May 2 '16 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.