You are not logged in.

#1 2022-06-07 18:08:59

dinoFP
Member
Registered: 2021-12-29
Posts: 3

[SOLVED] ssh > tmux attach > new-window fails

I've been trying to switch from using screen (for a long time!) to tmux and until today it had been going well. Having a problem with creating new windows after ssh in and attaching to an existing session. Here are the steps:

1. On machine1 `tmux new -s test1`
2. Can `C-b c` and the new windows work fine
3. On machine2 `ssh sameusername@machine1`
4. Now, ssh'd into machine1 `tmux attach -d -t test1`
5. tmux session looks fine, can switch between *existing* windows in it
6. `C-b c` opens a new window that's "hung", just an inverted character in the upper-left. No prompt. No response to keyboard. After a few seconds the name for this window in the status changes from "bash" to "sh" and then a few seconds later the new window gets killed and you're kicked back to the prior window that had focus.
7. Back on a local terminal on machine1, can new-window just fine still in the session. It's only broken for remote shells attaching.

This is tmux 3.2a and the terminal is rxvt-unicode 9.26-2. Arch on both systems upgraded within the past couple of weeks.

I tried doing some heavy logging of the tmux server with -vvv, not seeing anything that looks suspicious there but maybe I'm looking at it wrong.

I confirmed this behaves the same with no config at all, just plain vanilla tmux out-of-the-box.

I confirmed the problem occurs the same if you use one machine where you `ssh localhost` first. The important thing that breaks it is doing it after ssh.

I made sure this behavior happens with a fresh tmux server running (not one that's hosting a pile of sessions for days/weeks).

Hopefully this is just a config or permissions issue.

Last edited by dinoFP (2022-06-07 21:12:33)

Offline

#2 2022-06-07 21:11:58

dinoFP
Member
Registered: 2021-12-29
Posts: 3

Re: [SOLVED] ssh > tmux attach > new-window fails

I tried this on a different Arch system I have and was able to observe an error in the tmux window when the issue occurred:

/usr/lib/Xorg.wrap: Only console users are allowed to run the X server

Searching for this lead me to realize tmux opening the window after ssh and attach was trying to start an X server.

This is going to require some explaining...

I use a tiling WM (xmonad) and run a super lean X set-up with no display manager. To achieve that I have this I have code in my .bash_profile to start X:

...
# Start X
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- -keeptty >~/.xorg.log 2>&1

I wasn't expecting it but tmux defaults to launching shells as login shells. Also adding duplicate parts to the PATH, which is meh.

I get the idea of being able to attach after the user has logged out of a remote system, but I think non-login shell works better for me, at least on this machine.

To disable this behaviour, add to ~/.tmux.conf:

set -g default-command "${SHELL}"

Last edited by dinoFP (2022-06-07 21:13:34)

Offline

#3 2024-03-29 13:45:19

lv10
Member
Registered: 2021-06-24
Posts: 1

Re: [SOLVED] ssh > tmux attach > new-window fails

Thank you. Setting `default-command` to `${SHELL}` solve the problem for me. Whenever I ssh'd into my desktop I couldn't start new instances of `tmux` or new windows or panes.

I have a similar setup with i3wm with the idea of having a super lean setup for X.

Last edited by lv10 (2024-03-29 13:45:49)

Offline

Board footer

Powered by FluxBB