How to maintain a persistent SSH connection?

Phil Pennock phil.pennock at
Thu Nov 16 05:41:11 AEDT 2017

On 2017-11-15 at 14:08 +0100, martin f krafft wrote:
> What does not work fine, however, is the server-side. If the
> connection goes down, sshd(8) lingers on the remote, bound to the
> port that I need to forward back across the link. As a result, new
> connections can't bind the port.
> The sshd(8) process stays around for an unspecified time (>90min)
> after the connection went down.
> I realise I could use ClientAliveInterval on the server-side, but
> there seems to be no way to specify this per-connection, and
> there simply won't be a server-wide policy change in this case.

So, instead of running no command server side, would a suitable
workaround be to run 'while sleep 1; do echo .; done' as the server
command and discard stdout from ssh on the client side?  That way, the
server side should detect the dropped link sooner, leading to sshd exit
and port release.


More information about the openssh-unix-dev mailing list