ssh agent troubles

Jamon Camisso jamon.camisso-H217xnMUJC0sA/PxXw9srA at public.gmane.org
Mon Mar 18 23:08:07 UTC 2013


On 13-03-18 06:29 PM, Christopher Browne wrote:
> I'm running into an odd situation where my shell loses connectivity to
> ssh-agent.
> 
> I'll commonly set things up via:
> % ssh-agent zsh
> [which starts a fresh zsh, and all is good...]
> % ssh-add -l
> 2048 d3:b8:ab:c1:a8:f8:03:a7:31:b7:ad:a2:40:ec:70:40 cbbrowne at cbbrowne (RSA)
> 2048 03:c3:e6:2e:1a:8c:08:9c:84:ab:3f:0a:d9:2d:9a:71 cbbrowne at cbbrowne (RSA)
> 2048 31:34:0f:bc:90:bf:1f:fd:4a:49:7f:ad:44:04:4c:62 cbbrowne at wolfe (RSA)
> 
> Lovely, I have some of my favorite ssh keys in place.
> 
> But a little bit of time passes, and, for inexplicable reason, ability
> to connect
> fails.  I find my ssh connection requests asking either for passwords
> (for remote
> hosts) or for the passphrase for the key.
> 
> %  ssh-add -l
> Could not open a connection to your authentication agent.
> 
> I still have legitimate values for $SSH_AGENT_PID and $SSH_AUTH_SOCK, and if I
> search for the PID, it's an agent that's still running.
> % echo $SSH_AGENT_PID
> 2737
> % ps auxww | egrep 2737 | grep agent
> cbbrowne  2737  0.0  0.0  12392   772 ?        Ss   17:58   0:00 ssh-agent
> 
> Curiously, if I start another child shell, everything's fine again, for a little
> while...
> % ssh-agent zsh
> [new shell]
> % echo $SSH_AGENT_PID
> 2737
> 
> And I have intermittent success at using the agent, again.  Until it decides
> to stop.  Quoi?!?!?

You'll need to do three things to debug this:

1) start ssh-agent with -d to enable debug (non daemon mode). Do this
without spawning a zsh session to test. This is shell 1. If you want to
make it easy in step 2, start with -a and make an easy to remember agent
name.

2) In a second shell run strace on the pid of the ssh agent. Capture
this output to a file or somewhere safe for analysis. This is shell 2.

3) export the SSH_AGENT_PID and SSH_AUTH_SOCK variables in another fresh
shell. This is done in a new shell, shell 3.

Add your keys and operate as you normally would in shell 3, or 4 or 5 or
however many you want to use with the exported variables. I suggest
testing with bash as well to see if it is specific to zsh (I've never
encountered this).

The key is using the same auth socket and seeing what triggers the agent
to die via strace or the debug output from ssh-agent. If it is not
something you can reproduce, then I suspect it is something causing the
spawned zsh to exit silently, e.g. a ctrl+c or d or something.

Jamon

--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list