Hi

The way tmux works is that when you start the server the environment
(including SSH_AUTH_SOCK) is copied into the global environment and that
is used for all new panes.

Then by default SSH_AUTH_SOCK is updated from the shell into the session
environment when you attach (unless you change the update-environment
option), which means its new value will be used for new panes in the
attached session. But not for existing panes, tmux has no way to change
those. If you have an existing pane with the wrong SSH_AUTH_SOCK, you
will need to fix it yourself.

You will have to work out how that matches to what you are doing
yourself because what you describe makes no sense to me.

Using a new ssh-agent every time you login but keeping a tmux server
running all the time doesn't work well because SSH_AUTH_SOCK in all
existing panes in tmux will become out of date every time you start a
new ssh-agent.

It is better to start an ssh-agent the first time you log in (before you
start tmux the first time) and then use the same one forever so
SSH_AUTH_SOCK is not constantly changing. The easiest way to do that is
to do it in your shell profile with something like:

if [ ! -f ~/.ssh.agent ]; then
        ssh-agent -s >~/.ssh.agent
fi
eval `cat ~/.ssh.agent` >/dev/null
if ! kill -0 $SSH_AGENT_PID 2>/dev/null; then
        ssh-agent -s >~/.ssh.agent
        eval `cat ~/.ssh.agent` >/dev/null
fi


On Tue, May 19, 2020 at 07:31:17AM +0200, Jörg Kastning wrote:
> Hello tmux-users,
> 
> I don't know whether it is some kind of missing feature or I'm just stupid
> and don't understand it. So I'm in hope for some help.
> 
> My use case:
> I'm logging in to my machine via SSH and start the ssh-agent by running the
> command `exec ssh-agent bash` and add my private key afterwards. Next I
> start tmux which keeps the ssh-agent info in the first window. I've checked
> that via `echo $SSH_AUTH_SOCK`.
> 
> Now, when I create a new window the ssh-agent information are lost and `echo
> $SSH_AUTH_SOCK` returns an empty string.
> 
> Is there any way to keep the ssh-agent information?
> 
> And of course, thanks for this great piece of software. :-)
> 
> Kind regards,
> Joerg
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "tmux-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web, visit 
> https://groups.google.com/d/msgid/tmux-users/ffa770a1-111f-53e4-3787-dbf631c24ce8%40uni-bielefeld.de.


-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/tmux-users/20200519054742.ytbmacjugqvzr2mw%40yelena.

Reply via email to