How can I get ssh-agent working over ssh and in tmux (on OS X)?

Posted by Rich on Super User See other posts from Super User or by Rich
Published on 2011-01-25T22:25:37Z Indexed on 2012/03/23 11:33 UTC
Read the original article Hit count: 263

Filed under:
|

I have a private key set up for my github account, the passphrase to which is, I believe, stored in OS X's keychain. I certainly don't have to type it in when I open a terminal window and enter ssh [email protected].

However, when I'm running bash over an ssh session, or locally inside a tmux session, I have to type in the passphrase every single time I attempt to ssh to github.

This question suggests that a similar problem exists with screen, but I don't really understand the issue well enough to fix it in tmux. There's also this page which includes a fairly complicated solution, but for zsh.

EDIT:

In response to @Mikel's answer, from a local terminal I get the following output:

[~]
$ echo $SSH_AUTH_SOCK
/tmp/launch-S4HBD6/Listeners
[~] 
$ ssh-add -l
2048 [my key fingerprint] /Users/richie/.ssh/id_rsa (RSA)
[~]
$ typeset -p SSH_AUTH_SOCK
declare -x SSH_AUTH_SOCK="/tmp/launch-S4HBD6/Listeners"

Whereas over ssh or in tmux I get:

[~]
$ echo $SSH_AUTH_SOCK

[~]
$ ssh-add -l
Could not open a connection to your authentication agent.
[~]
$ typeset -p SSH_AUTH_SOCK
bash: typeset: SSH_AUTH_SOCK: not found

echo $SSH_AGENT_PID returns nothing whatever shell I run it from.

© Super User or respective owner

Related posts about tmux

Related posts about ssh-agent