Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
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
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks! That worked perfectly :) –  samspot Apr 25 '12 at 21:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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