In theory, an SSH connection can last indefinitely. It can be explicitly terminated by either side at the SSH layer (with a FIN
packet) or abnormally terminated at the TCP layer (with a RST
packet).
A RST
can happen if one side sends a packet and doesn't get a TCP acknowledgement in a reasonable amount of time. This usually happens because the other party is no longer there. It could also happen if there is a NAT or firewall in between that has stopped keeping track of the connection (usually due to lack of activity), so that the two parties can no longer communicate. More insidiously, a router at an evil ISP could inject RST
packets into the connection, but such measures are usually reserved to content that the ISP finds objectionable, such as BitTorrent.
Keep-alives can help keep connections alive by reminding NATs or firewalls to maintain the connection state. However, keep-alives can also hurt by making it more likely that a transient glitch in network connectivity would be noticed.
sshd_config
– Bratchley Aug 26 '13 at 01:32$TMOUT
as an example),ClientAliveInterval
is not being used in the sshd, your network connectivity stays stable and your client IP remains static. – Drav Sloan Aug 26 '13 at 02:41