38

I've added the OpenSSH client (Beta) feature on Windows 10 so I can call it by running

ssh

on the command line.

However the terminal windows (and thus the connection) freezes when inactive for too long. I know I would solve this on Linux by editing the ~/.ssh/config file. Is there an equivalent on Windows?

1

2 Answers 2

61

In C:\Users\yourusername\.ssh make a new file named config, and add the lines below:

Host *
    ServerAliveInterval 40
1
  • I believe 40 means a keep-alive request is sent every 40 seconds. Why 40? Would 240 (4 minutes) do the same job with fewer requests sent?
    – kbluue
    Commented Aug 26 at 9:21
27

You can solve this on the client side by setting the options ServerAliveInterval and ServerAliveCountMax (60 and 30 will send a keep-alive packet every minute and still keep the connection if your network falls for up to 30 minutes).

The Windows OpenSSH client has some issues finding the ssh_config file (it appears to have doubts about what the "home" directory is in a Windows System), so you may have to explicitly provide the config file path with -F:

ssh -F C:\wherever\ssh_config user@host

On the server side you can edit /etc/ssh/sshd_config, edit/add the similar ClientAliveInterval and ClientAliveMaxCount options and restart the sshd service.

1
  • You're right @FBergo - Windows tricky to get it to take effect and annoying to keep restarting terminal window. This hits the problem right on the head - works nicely. Commented Aug 27, 2023 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.