Tmux dies when logging out from remote

Hi everyone,
the problem is the following:

  • I ssh to a remote that has a fresh Manjaro Gnome install,
  • start a tmux session
  • detach from the session so that the session is still running in background
  • logout from the remote and login again to find that the tmux session doesn’t exist anymore

I found a thread discussing the problem
https://unix.stackexchange.com/questions/171503/tmux-session-killed-when-disconnecting-from-ssh
and the workaround
systemd-run --scope --user tmux
works for me, although it is a bit annoying to communicate it is to the other users of the machine.

Tmux used to work fine up to a few months ago, anyone knows what happened? Some policy change in systemd or openssh?

Do you have a better solution to the problem?

The accepted and highly upvoted answer says to:

If your processes get killed at the end of the session, it is possible that you are using socket activation and it gets killed by systemd when it notices that the SSH session process exited. In that case there are two solutions. One is to avoid using socket activation by using ssh.service instead of ssh.socket. The other is to set KillMode=process in the Service section of ssh@.service.

The KillMode=process setting may also be useful with the classic ssh.service, as it avoids killing the SSH session process or the screen or tmux processes when the server gets stopped or restarted.

So did that not work for you?

:thinking:

1 Like