0

Compliance requires a 10 minute timeout on ssh sessions.

I want to use tmux so I don't lose the stdout from long running processes.

[ -n "$PS1" -a -z "$TMUX" ] && exec tmux new-session -A -s main

What I expect is that when I reconnect I will reconnect to my existing session named main.

What actually happens is that when sshd detects I've been idle for 10 minutes, it ends the session instead of disconnecting it.

How do I ensure tmux disconnects when session times out, instead of exiting.

Edit:
Disconnecting the session and then reconnecting to the system works as desired.

Also, I have used tmux for this in the past, and it would faithfully reconnect me to my session. I commented the above line out for a couple of weeks and when I re-enabled it, the current behavior had started. I think the timeout was not enforced before though. So I guess this means that SSH is closing the session instead of disconnecting it.

2

1 Answer 1

0

Not sure why sshd ends the session, but you could use the tmux plugins resurrect and continuum to continuously store the state of your tmux session on disk.

Once you get kicked out by the timeout, you can reconnect and start a new tmux session again. If all is setup correctly, the continuum plugin will then automatically restore your last session (including panes, windows, etc...)

However, now that I've written this I am not sure if the stdout remains. Perhaps it's better to write it to a log file (or the syslog) and then read it from there?

3
  • The whole reason I wanted to use tmux is because it connects me back to my session. I'll look up the plugin. Not sure I can install it in the environment though :(. Configuration management, etc.
    – Jeter-work
    Jun 29, 2022 at 20:35
  • Yeah, it seems something is amiss with the sshd configuration. Please see the link I posted under your question to read about a similar problem. Perhaps the answers there can help you out (or can point your IT department in the right direction). Jun 29, 2022 at 20:40
  • That link led me to a multitude of other ideas. Our systems run stock RHEL/CentOS 7 and some Ubuntu 18. They seem to run sshd as a service already, not as a socket. One of the comments mentioned that the defaults for sshd recently changed to kill all processes started in the session. Which totally neuters tmux/screen. I'm exploring the 'tmux as a service' options. After I figure out how to do it at all, I will then need to make it work for everyone, including non-administrative users.
    – Jeter-work
    Jul 6, 2022 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .