Search code examples
windows-10opensshwindows-shell

How do I keep SSH connection alive on Windows 10?


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?


Solution

  • 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.