SSH: Set timeout for broken pipe
The option ClientAliveInterval
does exactly what you want, it basically sends pings in the specified interval (in seconds) and kills the connection if it doesn't receive an answer.
To control how fast it kills the connection, you can use ClientAliveCountMax
, which is the maximum number of pings to send without receiving a response before considering the connection dead.
Related videos on Youtube
Comments
-
Rapti over 1 year
ssh
has the paramater-o ConnectTimeout=10
to set the timeout in seconds when establishing the connection, but once the connection has been established, the parameter has no more effect. When an already established connection dies,ssh
takes an incredible amount of time before telling meBroken Pipe
. This is good in many cases as I can continue work after having network issues, but there are scenarios in which I want to use just a small timeout, maybe 10 to 20 seconds, for example when using tools likesshuttle
. How can I do this? -
Rapti almost 8 yearsSo if it sends a ping every 10 seconds and doesn't receive an answer, will
ssh
exit 10 seconds after unplugging the network cable etc? -
Lorenz almost 8 yearsSee my updated answer
-
Rapti almost 8 yearsThe options are called
ServerAliveInterval
andServerAliveCountMax
at least in my installation, but this works great. Thanks! -
Lorenz almost 8 years@Rapti Both options exist. These are the clientside options, yours the server side ones.
-
Rapti almost 8 yearsBut
ssh
gives me some error when trying to use the Client options.man
also only knows about the Server ones.