I have ServerAliveInterval and in case of few machines also ClientAliveInterval set to 540 in SSH client/server configuration files (I suppose setting it to more than that would not be a good idea). I work with many SSH sessions which currently freeze after a few minutes. How can I fix it? What I want is to have a session to not freeze at all, so that if I open a session at 8 and don't use it for 4 hours, for example, to still use it again at 12 without having to log-in again.
How can I keep my SSH sessions from freezing?
ssh
The changes you've made in /etc/ssh/ssh_config and /etc/ssh/sshd_config are correct but will still not have any effect.To get your configuration working, make these configuration changes on the client:/etc/ssh/ssh_config Host *ServerAliveInterval 100ServerAliveInterval  The client will send a null packet to the server every 100 seconds to keep the connection aliveNULL packet  Is sent by the server to the client. The same packet is sent by the client to the server. A TCP NULL packet does not contain any controlling flag like SYN, ACK, FIN etc. because the server does not require a reply from the client. The NULL packet is described here: https://tools.ietf.org/html/rfc6592Then configuring the sshd part on the server./etc/ssh/sshd_config ClientAliveInterval 60TCPKeepAlive yesClientAliveCountMax 10000ClientAliveInterval The server will wait 60 seconds before sending a null packet to the client to keep the connection aliveTCPKeepAlive Is there to ensure that certain firewalls don't drop idle connections. ClientAliveCountMax Server will send alive messages to the client even though it has not received any message back from the client.Finally restart the ssh serverservice ssh restart  or  service sshd restart depending on what system you are on.