23

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
  • 778
  • 1
  • 5
  • 16

2 Answers2

37

in C:\Users\yourusername\.ssh make a newfile named config,and add lines below:

Host *
    ServerAliveInterval 40
傅继晗
  • 679
  • 1
  • 6
  • 12
15

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
  • 906
  • 7
  • 10