Configure SSH server on Windows

2 minute read

Related:


The robust OpenSSH server on Cygwin allows SSHing into a Windows PC for secure port forwarding Windows RDP. Use Public Key Authentication – it’s far stronger than any human usable keyboard password.

Setup

  1. Cygwin SSH server prereq: from Windows Command Prompt:
    setup-x86_64 -P openssh
    
  2. Cygwin SSH server setup: start Cygwin64 using “Run as Administrator” and type
    ssh-host-config
    
    config response
    Privilege separation yes
    strict modes yes
    sshd as service yes
    value of CYGWIN for daemon (just press Enter key, don’t type anything)
    use a different name no (you want to use cyg_server)

Start

The Cygwin SSH server starts itself on reboot of Windows, but if you need to start it manually (e.g. for the first time upon installing)

cygrunsrv -S sshd

Test

  • login to your Windows Cygwin SSH server from another PC.
  • Under services.msc you should see the Status “started” for service “CYGWIN sshd”, and under the General tab the “path to executable” should be something like c:\cygwin64\bin\cygrunsrv.exe

Configure

Cygwin SSH server config is in /etc/sshd_config. To make changes take effect, type

cygrunsrv -E sshd
cygrunsrv -S sshd

Alternatives

Cygwin has been extremely robust for SSH servers, even running multiple SSH servers on distinct ports. However, I always like to use more native/OEM solutions, and there are two OpenSSH server solutions emerging from Microsoft for Windows: WSL or native OpenSSH server. I haven’t prioritized examining these alternatives since Cygwin has been so robust, and the alternatives only become viable in late 2017.

If you’re building a new Windows system that needs remote management, let’s talk. These alternatives, being baked into Windows from the factory, will be easier to support and more robust in the long term.

Windows Subsystem for Linux SSHD

Recent changes to Windows in Build ≥ 17046 allow sshd in WSL by using Task Scheduler to start SSHD on Windows boot.

If you are interested in SSHD server on Windows Subsystem for Linux, please let me know in the comments below.

native Windows OpenSSH server

Microsoft has been actively developing a native Windows OpenSSH server. In 2017, Microsoft allows executing WSL commands from the Windows Command Prompt, so this native Windows OpenSSH server became much more appealing.

If you are interested in native Windows SSHD server, please let me know in the comments below.

Notes

If you get

system error 1069 has occurred. The service did not start due to a logon failure

check the password on your “privileged server” cyg_server – maybe you typed it wrong.

Leave a Comment