MacOS – ssh under tmux always asks for password

macossshtmux

Normally I give my passphrase for the private key on the first ssh invocation and then I am not asked for the passphrase (in this and all other bash sessions).

However, under tmux, I am asked for the passphrase over and over even in the same bash (same tmux pane).

I think the problem originated with the Sierra.

How do I avoid having to enter my passphrase repeatedly under tmux?

PS. ssh-add -l prints The agent has no identities. both with and without tmux.

PPS. $SSH_AUTH_SOCK names an existing socket under /private/tmp....

Best Answer

Open a new terminal window and run the following commands:

$ tmux new -s temp
$ ssh-agent
$ ssh-add

That seems to have fixed the issue for me; new tmux sessions now no longer ask me for my ssh key passphrase.