/usr/share/doc/autossh/README.Debian says:
[...]
Note: if your ssh client/server version is recent enough you can
obtain similar behaviour by setting ClientAliveCountMax and
ServerAliveInterval in /etc/ssh/sshd_config. See sshd_config(5).
This echoes a recommendation made by autossh's author, and it is
supposedly a superior method of accomplishing connection monitoring.
Given this, and that you know the range of SSH versions that will be
installed along side this Debian package (which should all be new enough
to support this...unless you're trying to support non-openssh clients
like dropbear), I recommend eliminating the random port selection logic
in the wrapper script, and instead have the wrapper script (pre)append
SSH options to implement the above.
Something like:
if [...existing code to skip this if -M or AUTOSSH_PORT is set...]
export AUTOSSH_PORT=0
monitor=("-o" "ServerAliveInterval ${AUTOSSH_POLL:=300}")
fi
exec /usr/lib/autossh/autossh "${monitor[@]}" "$@"
Technically, it needs to be a little more sophisticated, as it should
insert "${monitor[@]}" after the occurrence of a "--" parameter, if it
exists.
-Tom
Thanks for the hint but how to know if the server will correctly reply to alive messages sent by the client? This also requires knowing what protocol version is being used. My point is that with aliveinterval enabled it becomes rather easy to implement something like autossh with a shell script, anyhow it can be considered as an option to the debian wrapper. filippo -- Filippo Giunchedi - http://esaurito.net - 0x6B79D401 UNIX was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things. -- Doug Gwyn
Filippo Giunchedi wrote: True. As I recall, that feature requires version 2.0 of the protocol. I forgot about that. Of course the ssh client knows this, and could be designed to use randomly selected monitoring ports as a fallback (and without the race condition that the wrapper script has). But that requires patching OpenSSH. The autossh author said likewise. With most of the heavy lifting having already been implemented in OpenSSH, it might be a good time to develop a patch for OpenSSH to finish the job, if anyone is so inclined. This would provide additional advantages over autossh as well, such as having logic to distinguish between temporary network failures and permanent syntax, startup, or protocol failures. Right, I could see it still being useful as a matter of convenience, as long as the limitations are documented and it can be disabled. Maybe if -M 0 disables the monitoring, -M -1 could cause the wrapper to trigger the OpenSSH built-in monitoring? (The script would pass -M 0 on to autossh.) -Tom
I am forwarding this bug to upstream as he might be interested in implementing it. filippo -- Filippo Giunchedi - http://esaurito.net - 0x6B79D401 It is easier to change the specification to fit the program than vice versa. -- Alan Perlis
I am forwarding this bug to upstream as he might be interested in implementing it. filippo -- Filippo Giunchedi - http://esaurito.net - 0x6B79D401 It is easier to change the specification to fit the program than vice versa. -- Alan Perlis