31

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?

SlowerPhoton
  • 888
  • 1
  • 7
  • 17

2 Answers2

51

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

Host *
    ServerAliveInterval 40
jdgregson
  • 1,457
  • 17
  • 39
傅继晗
  • 927
  • 1
  • 8
  • 14
21

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.

FBergo
  • 1,010
  • 8
  • 11
  • 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. – TickboxPhil Aug 27 '23 at 15:30