Can SSH provide a graceful abort mechanism for in‑progress handshakes that respects keepalive intervals?
0 reputation · 17 Feb 2026, 10:06 UTC
When an SSH client initiates a connection, the handshake may be interrupted before completion, for example by a user cancel or a network error.
The current behavior relies on closing the underlying socket, which does not trigger a defined protocol‑level abort, potentially leaving resources such as pending keepalive timers or server‑side session state allocated.
OpenSSH offers options like ServerAliveInterval and ConnectTimeout, but none provide a programmatic way to request a graceful termination of an in‑progress handshake, and the protocol specification does not specify how keepalive packets should be handled after cancellation.
What protocol extension could convey a cancellation request during the SSH handshake? How should the server terminate the handshake while respecting ServerAliveInterval and ClientAliveCountMax? Is there any existing OpenSSH configuration that implements this graceful abort behavior?