ssh connection randomly times out

Darren Tucker dtucker at dtucker.net
Sat Sep 19 06:02:17 AEST 2026


On Fri, 18 Sept 2026 at 12:19, James Moe via openssh-unix-dev
<openssh-unix-dev at mindrot.org> wrote:
[...]
> I establish a connection to a remote host. After some random length of time
> (minutes, hours), the connection becomes unresponsive. After a further period
> the connection is terminated:

Determine the IP addresses and port numbers for your connection.  The
~I escape sequence on the client and $SSH_CONNECTION on the server can
help with this.  Note that in the presence of NAT, these may not match
on both ends.

After it becomes non-responsive and before it terminates, run
"netstat" on both ends and find the connection.  They'll look
something like this:

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 10.68.96.68:55408       10.167.129.32:22        ESTABLISHED

If there's a non-zero number in the Send-Q column that never decreases
then that means TCP is no longer able to deliver packets in your
connection and your network is broken somehow.  Common causes for this
are path MTU problems and intermediate network devices running out of
state table space.

In some cases, enabling SSH keepalives
(ServerAliveInterval/ServerAliveCountMax on the client) can help in
the case of your connection's state being GCed.  In the case of MTU
problems reducing the MTU on either end can help (576 is the minimum
that should always work, but at the cost of efficiency).

-- 
Darren Tucker (dtucker at dtucker.net)
GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860  37F4 9357 ECEF 11EA A6FA
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.


More information about the openssh-unix-dev mailing list