I mainly work on a mac and ssh/tmux attach to a Linux machine to do my work. I have ssh-agent running on the Linux machine. I have
set -g update-environment "SSH_AUTH_SOCK SSH_ASKPASS WINDOWID SSH_CONNECTION XAUTHORITY"
in my .tmux.conf
. Yet, whenever I re-attach to this session, I have to run
tmux setenv SSH_AUTH_SOCK $SSH_AUTH_SOCK
in order for new tmux windows to have $SSH_AUTH_SOCK
set correctly. I would prefer to not have to do this. Any ideas?
Update
I think I'm not explaining this well. Here's my shell function to open a shell on a remote machine:
sshh () {
tmux -u neww -n ${host} "ssh -Xt ${host} $*"
}
When tmux runs this ssh command, $SSH_AUTH_SOCK
is not set, even though it is set in my local environment. If I put this in tmux's environment with the setenv
command above, everything works fine. My question is, why do I have to run the setenv command at all?
Update 2
More information:
When I attach to an existing session, $SSH_AUTH_SOCK
is not set in the tmux environment (or global environment).
% tmux showenv | grep -i auth_sock
-SSH_AUTH_SOCK
If I set it manually, things work:
% tmux setenv SSH_AUTH_SOCK $SSH_AUTH_SOCK
If I detach and re-attach, $SSH_AUTH_SOCK
goes back to not being set.
env
?