Cygwin ssh server is not accepting connections

Solution 1:

You may have Windows Firewall running. Open: Control Panel -> Windows Firewall -> Allow a program or feature through Windows Firewall

Click the "Change settings" button then the "Allow another program..." button. SSHD is probably not in the list that comes up, so use the "Browse..." button to find the binary and click "Open" and then "Add". Mine was in C:\cygwin\usr\sbin\sshd.exe

Somewhere in there you can decide which "Network location types..." you want to use. I left mine with Private checked and public unchecked. I can now login remotely.

Solution 2:

Does your sshd_config specify ListenAddress as 0.0.0.0 or 127.0.0.1?

If it's 0.0.0.0 or just commented out, then you can connect from outside the machine, ie, from another computer.

If it's 127.0.0.1 (or any other 127.0.0.x number), then it's ONLY listening on the LOCALHOST, and you can only log in from the SAME machine. External machines are denied.

Solution 3:

After messing around with windows firewall to no effect I eventually found I had to allow connections to my own subnet in Cygwin itself via the /etc/hosts.allow file.

This line (using my subnet) as the first rule fixed the issue for me.

ALL : 192.168.0.0/24 : allow

Solution 4:

For me the issue was with incorrect ownership of the /var/empty file. The problem became obvious after putting sshd in debug mode with /usr/sbin/sshd.exe -D -dd. I had to correct it with:

chown [user]:[group] /var/empty

User and group were taken from the ls -la /var directory (just matched other files). See more info here: https://docs.oracle.com/cd/E24628_01/install.121/e22624/preinstall_req_cygwin_ssh.htm#EMBSC340