2

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?

3
  • 1
    Do you happen to have TMOUT set in your environment?
    – doneal24
    Mar 8, 2022 at 19:36
  • Oh, wow, good call. It is set to 900, which matches the 15 minute timeout I am seeing. Is that a per user (user I am ssh-ing to) setting? And it looks like 0 is never?
    – zenzic
    Mar 8, 2022 at 21:17
  • Thanks @doneal24, between that and the config changes suggested below, things are behaving much better. Thanks for the response!
    – zenzic
    Mar 8, 2022 at 21:58

1 Answer 1

2

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.

2
  • 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.
    – zenzic
    Mar 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!
    – zenzic
    Mar 8, 2022 at 21:55

You must log in to answer this question.

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