0

My goal is to increase my ssh connection timeout on my server, where I have limited permisssions. I do not have permission to even read /etc/ssh/sshd_config (nor append/write) and I do not have sudo.

Locally on my PC, I already did in ~/.ssh/config:

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

However, even after reloading my local ssh deamon (sudo systemctl reload sshd), my connection would break much sooner than expected.

My question is: Is there a different way to tell to my server to keep my connection alive, different than the standard global solution of modifying /etc/ssh/sshd_config with ClientAliveInterval X?

1
  • (1) If I understand you right, your local SSH server is totally irrelevant. You connect a local client to some other (non-local) server, right? Even if you connected to the local server, ~/.ssh/config is still the client config anyway. Reloading the local server is therefore futile for sure. (2) This is how these *Alive* settings work. If ServerAlive* don't help ten probably there is another culprit. What message (if any) do you get locally when disconnected? Commented Feb 14, 2022 at 12:43

1 Answer 1

0

You need to identify how long it takes for an idle session to get timed out. (If you're getting timeouts across sessions that are not idle then we're chasing the wrong type of solution.)

For example, if it's one minute, then set the Keepalive to half that, i.e. 30 seconds.

I'd recommend that you don't change the default setting (Host *) but instead create a specific entry for the target host and all the possible aliases that you might use to connect to it. If you also have a default setting (Host *), where for example you set the default target username, ensure that this specific entry is listed before the default.

Host myServer myServerAlias myServer.my.domain 10.11.12.13
    ServerAliveInterval 30

It's worth taking the time to try and identify the timeout period and halving that, as blindly sending a keepalive every 30 seconds is wasteful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .