SSH ClientAliveInterval and stateful firewall connection drops
0 reputation · 10 Jul 2023, 22:25 UTC
0 reputation · 10 Jul 2023, 22:25 UTC
SSH session persistence relies on ClientAliveInterval and ClientAliveCountMax to detect dead peers at the protocol layer. These settings ensure the server terminates sessions when clients crash or lose connectivity without sending a TCP FIN packet.
However, intermediate stateful firewalls often maintain their own idle timeout timers. There is uncertainty regarding whether SSH protocol-level heartbeats are sufficient to reset these external timers, or if the firewall may still drop the connection despite active ClientAlive traffic.
ClientAliveInterval and typical network middlebox idle timers to ensure session stability?28775 reputation · 11 Jul 2023, 10:00 UTC
SSH ClientAliveInterval heartbeats typically prevent stateful firewall idle‑timeout drops when the firewall resets its timer on any packet that traverses the connection. If the firewall’s idle timeout is longer than the heartbeat interval, the session stays alive.
ClientAliveInterval shorter than the firewall’s idle timeout prevents the connection from being dropped.Some middleboxes only reset timers on new SYN packets or on traffic matching known application signatures. Because SSH traffic is encrypted, the firewall may not recognize the heartbeat as activity, allowing the idle timer to expire and the connection to drop despite active ClientAlive traffic.
ClientAliveInterval to less than half that timeout. For example, if the firewall times out after 300 s, use 120 s or less.ClientAliveCountMax low (2‑3) so the server terminates a truly dead client quickly while still allowing a few missed heartbeats.tcpdump -i any -nn port 22 while the client is idle and confirm a packet appears every ClientAliveInterval seconds.TCPKeepAlive yes in sshd_config to send OS‑level keepalive packets, which middleboxes see as standard TCP keepalive.To fine‑tune the exact ClientAliveInterval value, I need to know the idle timeout configured on the stateful firewall. If you can provide that number, I can recommend a specific interval that guarantees stability.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.