"ssh connection refused" error sometimes.

来源:互联网 发布:软件windowsphone 编辑:程序博客网 时间:2024/05/16 21:11

Issues: 

Got  "ssh connection refused" error sometimes.  Tried below:

1. Ping the IP(10.19.224.105) and could ping without problem. 

2. Using ssh root@10.19.224.105 to ssh the host, got the "ssh connection refused" error, but sometimes i could ssh to login without problem. 


How to resolve:

1. Use "arping" to check if the there is the IP conflict issues, and the same IP was assigned to the different MAC address.  After checking, there were two MAC responded the ping. 

test@test-ubuntu10:~$ sudo arping 10.19.224.105

ARPING 10.19.224.105 from 10.19.224.129 eth0
Unicast reply from 10.19.224.105 [00:50:C2:70:49:4F]  1.045ms
Unicast reply from 10.19.224.105 [E0:3F:49:80:7C:7E]  1.166ms
Unicast reply from 10.19.224.105 [E0:3F:49:80:7C:7E]  1.145ms
^CSent 2 probes (1 broadcast(s))

host@host-ubuntu:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr e0:3f:49:80:7c:7e  
          inet addr:10.19.224.15  Bcast:10.19.224.255  Mask:255.255.255.0
          inet6 addr: fe80::e23f:49ff:fe80:7c7e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5628 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1734 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:599545 (599.5 KB)  TX bytes:177451 (177.4 KB)
          Interrupt:45 


2. To confirm above conclusion, shutdown the host machine, and check if 10.19.224.105 could be pinged successfully. If yes, then the IP conflict issue was confirmed, and we could assigned the IP to another one. Then issue could be resolved. 


Referred net webs:

http://askubuntu.com/questions/30080/how-to-solve-connection-refused-errors-in-ssh-connection


Some tips:

===========================================================================

Tips One: 

Use arping on the IP address that is having connection issues. That will show the MAC address for each ping reply, and hopefully will unmask the rogue MAC address.

arping 192.168.2.254

You should check the DHCP IP address pool on the DHCP server, make sure no devices have static IPs that collide with the DHCP pool.

These clues point to duplicate IP:

  • ping ttl and round trip time looks like 2 distinct servers
  • intermittent disconnects without rebooting


Tips Two: 

What do you get if you do this :-

cat /etc/hosts.deny |  grep 192.168.2.25

If that returns anything then you need to remove it.


Tips Three: 

IP address conflict turned out to be the root cause when I was seeing this SSH error message.

After reading the answers above I suspected an IP address conflict, but needed to prove that address conflict was or was not the problem.

This great article showed how to use arp-scan to see if two pieces of hardware were claiming the same IP address.

In my case the server machine had a static ip address of 192.168.1.42, I used arp-scan to check that address:

$ sudo apt-get install arp-scan$ arp-scan -I eth0 -l | grep 192.168.1.42  192.168.1.42 d4:eb:9a:f2:11:a1 (Unknown)  192.168.1.42 f4:23:a4:38:b5:76 (Unknown) (DUP: 2)

Sure enough there was a conflict, as shown above. Then I ran arp-scan without the grep, found that .43 was available, went and edited /etc/network/interfaces and changed the static ip from .42 to .43


===========================================================================


0 0
原创粉丝点击