Centos – SSH Connection refused from remote host

centosssh

I have 2 VPS running on CentOS 6, Server1 and Server2. I can access both servers with SSH from my PC, but when I connect from Server2 to Server1 using this command:

ssh root@xxx.xx.xxx.x -p 22 

I get this error:

Unable to connect to xxx.xx.xxx.x:22: Connection refused

This is only happening for Server2. Server1 can connect to Server2 without any problems.

I am sure my SSH port is 22, I have stopped iptables on both servers and I have checked host allow and deny config. How can I fix this?

Best Answer

First to ssh to another server on port 22 you dont need the -p switch. It is the default port and ssh would able to complete without specifying that. Basically you want to see if port 22 is open between the servers. A simple telnet client should suffice. Do the following command on shell prompt.

telnet servername 22

If you see some text like openssh and then back to shell prompt, then it is not firewall issue.