I'm using iterm2 to SSH from a Mac to an RHEL server. ServerAliveInterval
is set to 60 in the client SSH config and TCPKeepAlive
is set to 'yes' in the server sshd config. However, idle sessions always timeout after some period (I have not timed it). Running sessions, e.g. a long-running process or a tail
will stay alive indefinitely. Is there some way to keep idle sessions alive using some combination of server, client, and iterm2 settings that I have been unable to find?
1 Answer
I am using ServerAliveInterval
on a client side together with ClientAliveInterval
on a server side for that purpose and I haven't seen drops (except the case of total loss of connectivity) in years.
I don't set TCPKeepALive
but I believe it is on by default (but I doubt it is ever generated as my above settings are in a range which likely prevents it).
For the case when the connection drops/hangs I suggest using tmux
or screen
and run a program inside it. You will be able to resume the session on subsequent connection. This of course only works for command line / text applications, X forwarding will break.
EDIT:
I am using:
ClientAliveInterval 60
ClientAliveCountMax 5
and
ServerAliveInterval 30
ServerAliveCountMax 10
I probably should change the latter to match the former.
-
ClientAliveInterval
is set to 300. I think it is timing out longer than 5 minutes, but I will lower that to 60 to see if it helps. Thanks for the suggestion. I do use screen and/or tmux (can't decide which I prefer) for network drops, but my immediate problem is that I just hate having to restart idle sessions every time I go to do something.– zenzicMar 8, 2022 at 18:58 -
I added both your changes and set TMOUT to 0 as suggested by @doneal24 and it has not timed me out after 30+ minutes. Thanks!– zenzicMar 8, 2022 at 21:55
TMOUT
set in your environment?