Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
When you access from home, are you using root also? –  John Siu Dec 25 '12 at 4:46
1  
have you check the port 22 by doing port scanning? –  user128296 Dec 25 '12 at 8:23
1  
Can you print the verbose output of the ssh connection with option -v in command ssh? –  Somesh Dec 25 '12 at 9:41
1  
Can you post tail /var/log/secure immediately after failing from server1? (You may want to censor some private information) –  Grumpy Dec 25 '12 at 14:45

3 Answers 3

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.

share|improve this answer

Check whether a root login is permited on server 2, if it is run ssh with the -vvv flag, you should see what's causing the failure.

share|improve this answer
    
You would not get "connection refused" -- just "authentication failed". "Connection refused" means that ssh was not able to establish a tcp connection. –  mricon Dec 25 '12 at 15:20

I can at least tell you where it is stuck. Three common debugging approach would be in this order.

ssh -vvvv root@<XX.XX.XX.XX>

Check where it is throwing error after giving the password. Use pastebin if you want us to see.

strace -ffttTo /tmp/strace.out ssh root@<XX.XX.XX.XX>

Again use pastebin if you want us to see the strace data.

Last and most lethal,

tcpdump  -s0 -i ethX 'port 22' -w /tmp/ssh.pcap 
ssh root@<XX.XX.XX.XX>

When ssh fails, hit ctrl-c to stop tcpdump. Obviously, you need to ssh from different konsole.

Don't give this data to us, people will be able to see everything.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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