Don't nest tmux in a remote ssh shell
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I've set up the .zshrc
of my user account on all of the hosts to which I connect to automatically start tmux
on login as long as it's not already running.
if [ -z "$TMUX" ]; then
tmux attach -d || tmux new
fi
This works well until I ssh (or mosh) into my own account on a remote host from within a tmux session on the local host. Since the $TMUX
macro isn't passed from the local host to the remote, tmux launches on the remote host and I now have two nested tmux sessions.
Is there a way to avoid this while keeping the auto-launching behaviour? Ideally I'd like the remote shell to know that it's being launched from within a tmux session on the host that is connecting and to not launch a second tmux instance.
I've already tried checking $TERM
in the remote shell but it is always xterm-256color
regardless of whether it is running within a tmux session on the local machine.
shell ssh tmux mosh
add a comment |Â
up vote
0
down vote
favorite
I've set up the .zshrc
of my user account on all of the hosts to which I connect to automatically start tmux
on login as long as it's not already running.
if [ -z "$TMUX" ]; then
tmux attach -d || tmux new
fi
This works well until I ssh (or mosh) into my own account on a remote host from within a tmux session on the local host. Since the $TMUX
macro isn't passed from the local host to the remote, tmux launches on the remote host and I now have two nested tmux sessions.
Is there a way to avoid this while keeping the auto-launching behaviour? Ideally I'd like the remote shell to know that it's being launched from within a tmux session on the host that is connecting and to not launch a second tmux instance.
I've already tried checking $TERM
in the remote shell but it is always xterm-256color
regardless of whether it is running within a tmux session on the local machine.
shell ssh tmux mosh
3
Related: How to pass environment variables to a new ssh-initiated login session
â Mark Plotnick
Jan 30 at 17:28
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've set up the .zshrc
of my user account on all of the hosts to which I connect to automatically start tmux
on login as long as it's not already running.
if [ -z "$TMUX" ]; then
tmux attach -d || tmux new
fi
This works well until I ssh (or mosh) into my own account on a remote host from within a tmux session on the local host. Since the $TMUX
macro isn't passed from the local host to the remote, tmux launches on the remote host and I now have two nested tmux sessions.
Is there a way to avoid this while keeping the auto-launching behaviour? Ideally I'd like the remote shell to know that it's being launched from within a tmux session on the host that is connecting and to not launch a second tmux instance.
I've already tried checking $TERM
in the remote shell but it is always xterm-256color
regardless of whether it is running within a tmux session on the local machine.
shell ssh tmux mosh
I've set up the .zshrc
of my user account on all of the hosts to which I connect to automatically start tmux
on login as long as it's not already running.
if [ -z "$TMUX" ]; then
tmux attach -d || tmux new
fi
This works well until I ssh (or mosh) into my own account on a remote host from within a tmux session on the local host. Since the $TMUX
macro isn't passed from the local host to the remote, tmux launches on the remote host and I now have two nested tmux sessions.
Is there a way to avoid this while keeping the auto-launching behaviour? Ideally I'd like the remote shell to know that it's being launched from within a tmux session on the host that is connecting and to not launch a second tmux instance.
I've already tried checking $TERM
in the remote shell but it is always xterm-256color
regardless of whether it is running within a tmux session on the local machine.
shell ssh tmux mosh
asked Jan 30 at 17:23
Gene Goykhman
1112
1112
3
Related: How to pass environment variables to a new ssh-initiated login session
â Mark Plotnick
Jan 30 at 17:28
add a comment |Â
3
Related: How to pass environment variables to a new ssh-initiated login session
â Mark Plotnick
Jan 30 at 17:28
3
3
Related: How to pass environment variables to a new ssh-initiated login session
â Mark Plotnick
Jan 30 at 17:28
Related: How to pass environment variables to a new ssh-initiated login session
â Mark Plotnick
Jan 30 at 17:28
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Thanks to @mark-plotnick 's comment I think I have solution that works for me.
On the remote host, add to /etc/ssh/sshd_config:
AcceptEnv TMUX
On the local host, add to ~/.ssh/config:
Host *
SendEnv TMUX
Now the value of the $TMUX
env variable is sent to the remote host, and tmux
no longer launches when the value is non-blank.
I don't mind making the server-side change but I wish I didn't have to edit every client ~/.ssh/config
so I'm open to additional suggestions.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Thanks to @mark-plotnick 's comment I think I have solution that works for me.
On the remote host, add to /etc/ssh/sshd_config:
AcceptEnv TMUX
On the local host, add to ~/.ssh/config:
Host *
SendEnv TMUX
Now the value of the $TMUX
env variable is sent to the remote host, and tmux
no longer launches when the value is non-blank.
I don't mind making the server-side change but I wish I didn't have to edit every client ~/.ssh/config
so I'm open to additional suggestions.
add a comment |Â
up vote
1
down vote
Thanks to @mark-plotnick 's comment I think I have solution that works for me.
On the remote host, add to /etc/ssh/sshd_config:
AcceptEnv TMUX
On the local host, add to ~/.ssh/config:
Host *
SendEnv TMUX
Now the value of the $TMUX
env variable is sent to the remote host, and tmux
no longer launches when the value is non-blank.
I don't mind making the server-side change but I wish I didn't have to edit every client ~/.ssh/config
so I'm open to additional suggestions.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Thanks to @mark-plotnick 's comment I think I have solution that works for me.
On the remote host, add to /etc/ssh/sshd_config:
AcceptEnv TMUX
On the local host, add to ~/.ssh/config:
Host *
SendEnv TMUX
Now the value of the $TMUX
env variable is sent to the remote host, and tmux
no longer launches when the value is non-blank.
I don't mind making the server-side change but I wish I didn't have to edit every client ~/.ssh/config
so I'm open to additional suggestions.
Thanks to @mark-plotnick 's comment I think I have solution that works for me.
On the remote host, add to /etc/ssh/sshd_config:
AcceptEnv TMUX
On the local host, add to ~/.ssh/config:
Host *
SendEnv TMUX
Now the value of the $TMUX
env variable is sent to the remote host, and tmux
no longer launches when the value is non-blank.
I don't mind making the server-side change but I wish I didn't have to edit every client ~/.ssh/config
so I'm open to additional suggestions.
answered Jan 30 at 19:01
Gene Goykhman
1112
1112
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420733%2fdont-nest-tmux-in-a-remote-ssh-shell%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
Related: How to pass environment variables to a new ssh-initiated login session
â Mark Plotnick
Jan 30 at 17:28