I set up a ssh server through ssh-host-config. Then I started the server.

net start sshd
The CYGWIN sshd service is starting.
The CYGWIN sshd service was started successfully.

When I try to connect I get:

ssh myusername@localhost
ssh: connect to host localhost port 22: Connection refused

I tried to allow port 22 in Windows Firewall, but that didn't change anything. And because I'm trying to ssh locally I don't think Windows Firewall is the culprit.

I'm using Windows 7 and

What should I look for to fix this problem?

  • Enable telnet command and checking with telnet localhost 22? – quanta Jul 28 '11 at 17:16
  • Can you post the output from 'netstat -an | grep 22' – EightBitTony Jul 28 '11 at 17:24
  • @EightBitTony: the original poster is using Windows 7, he should use findstr instead of grep. – quanta Jul 29 '11 at 2:39
  • $ netstat -an | grep 22 TCP LISTENING TCP ESTABLISHED – Steven Wexler Jul 29 '11 at 6:27

From the netstat output (which you might want to move into your question), the SSHD daemon is not listening on port 22. Which probably means although it started, it then crashed or stopped.

Try running sshd -d -d

That will run sshd in the foreground with debugging turned on, and you can see if / why it's crashing.


It is clear from the netstat output that either sshd is not listening on port 22 or the service is not running (crash on start). Best place to look for in windows would be event viewer in control panel. Also in the services.msc, see if it logging. If it is logging , logs would tell you what is happening and hence you would find the fix. Open resource monitor and see if the process sshd is running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.