I am attempting to SSH into my host. I'm using Mac OSX. When in terminal I type:

ssh user@hostname

I get an immediate error message stating:

connect to host xx.xx.xxx.xx port 22: connection refused

I've tried SSHing into my EC2 instance(different host altogether) and I can do that just fine. Any idea what the problem might be or what further troubleshooting I can do to find out the problem and fix it?

  • you'll need to provide more information. try verbose logging. have you ever been able to connect. what's the history of this host? have you checked firewalls? is ssh running (check out of band)? Sep 3 '13 at 6:22

This indicates that the ssh daemon is not running or that there is a firewall set to reject the connection.


On the system you are trying too sh to, run the following:

ps aux | grep ssh
netstat -tulpn | grep 22

You dont specify what operating system the target host is. If its Mac you may have to modify the netstat command line parameters. But simply, you need to list listening ports, and grep for port 22 which is what ssh runs on.

If you get no output from either of the above, especially the second command, then you sshd daemon is not running, and you will need to start it before you can connect.

That said, an immediate error would suggest ( as Richard mentioned ) that a firewall is blocking the connection.

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