Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an Ubuntu Server 10.10 32-bit in my home. I'm making SSH connections to it from my PC via Putty.

The problem is, sometimes I'm able to login seamlessly. However, sometimes it gives me an error like this: Network error: Connection refused.

Then, I dont't change anything, try to login a few times more, wait a while and try again. Sometimes I can log in, sometimes I cannot. It seems pretty random to me.

What can I do to solve this?

Edit:

And Sometimes, Putty gives Network error: Software caused connection abort error after displaying login as: text.

Here is the ping -t output:

Pinging 192.168.2.254 with 32 bytes of data:
Reply from 192.168.2.254: bytes=32 time=6ms TTL=64
Reply from 192.168.2.254: bytes=32 time=65ms TTL=6
Reply from 192.168.2.254: bytes=32 time=88ms TTL=6
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=3ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64
Reply from 192.168.2.254: bytes=32 time=1ms TTL=64

I turned off firewall of router, and everything seems to work now. Except for that, I still can't enter my web server by typing external IP from my PC.

share|improve this question
    
next time it craps out like that; run a ping on it again, does it still work? how many people ssh to this machine? –  myusuf3 Mar 13 '11 at 4:33
    
Only I ssh this server. –  frbry Mar 13 '11 at 12:03
    
Exactly the same problem here, also getting a mix of successful connects (which then work for hours), 'connection refused' and 'software caused connection abort' after the login or password entry. To provide some additional details: in my case it's a 64-bit virtual machine (running Ubuntu Server 10.10) on a Microsoft Hyper-V host, using the "old network card" emulation. –  hheimbuerger Mar 31 '11 at 12:24
    
SSH is installed on your server? –  Will Jan 8 at 18:27
add comment

10 Answers

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

share|improve this answer
    
Actually running that command showed only one line on my box, except that the name was that of another device. –  assylias Jul 25 '12 at 23:26
add comment

I had the same problem, even though I had a static IP address. Turns out another server on my network had been assigned the same (static) IP address. (Duh.) So it does appear that the problem is caused by IP address conflicts, but there may be various possible ways they can happen. If you set yours to static and still have a problem, try shutting down your machine and pinging the address. If you get any replies, start looking for what else could have the same address.

share|improve this answer
    
I experienced the same symptoms and tracked it down to a machine with the same IP address as the server. –  SabreWolfy Dec 7 '11 at 15:05
add comment

I can confirm this exact issue: It's not a simple connectivity issue. The ethernet link does not change state; server is reachable via ping; ssh connects flawlessly occasionally, then seemingly randomly does not connect or existing ssh session drops. This occurs on Ubuntu 10.04 and 11.04. Following hheimbuerger's suggestion I gave the server a static IP, this seemed to fix it.

Workaround: Change adapter from DHCP to static.

share|improve this answer
add comment

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
share|improve this answer
add comment

This looks more of a problem of your network equipment than the server itself.

Check /var/log/messages for ethernet link up/downs (or wlan in case of wireless). If so try changing the cables.

share|improve this answer
    
Yes, i tried and succeeded in making an ssh connection from outside of my network (which my server and my PC are located in). It seems working well. My server is also a web server. When I try to connect over port 80 from my PC, i see my ADSL modem's login page. But when I try the same thing from another computer which is outside my network, I see Apache's It Works page. –  frbry Mar 12 '11 at 19:08
    
What is you PC ip, your server ip and your internal adsl router ip? –  forcefsck Mar 12 '11 at 19:22
    
PC: 192.168.2.2 (Received from DHCP) Server: 192.168.2.254 (Static, out of DHCP range) ADSL Router: 192.168.2.1 –  frbry Mar 12 '11 at 19:24
    
I'm a bit confused, when you connect from 192.168.2.2 to 192.168.2.254 port 80 you get the adsl modem's login? –  forcefsck Mar 12 '11 at 19:54
1  
Unless you have setup some kind of web proxy to your server, then clearly your adsl modem is responding to requests made to 192.168.2.254 and probably that's the case when you get the Connection refused error with ssh. So you have to recheck the settings of your adsl modem. –  forcefsck Mar 12 '11 at 20:27
show 1 more comment

I had exactly the same issue, and in my case it turned out to be an IP address conflict. My Ubuntu VM had a dynamic address, but another machine (in this case a phone) had a static IP assigned that the DHCP server did not know about.

Just changing the IP that was assigned by the DHCP server to the Ubuntu VM fixed all connection issues.

share|improve this answer
add comment

You must install openssh-server on Linux before this will work. Get the internal IP address of Ubuntu and use that IP to setup port forwarding on port 22 (SSH) section of your router. Although if you don't intend to SSH from outside your network, this is not required.

Here's how to install openssh-server:

sudo apt-get install openssh-server openssh-client
[ENTER PASSWORD]
share|improve this answer
add comment

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.

share|improve this answer
    
That's one of the infamous "useless uses of cat" - you can simply grep 192.168.2.25 /etc/hosts.deny –  Tobias Kienzler Feb 26 at 8:19
add comment

You might want to check your iptables rules on your server. It sounds like you've a rule for limiting new SSH connections.

The next rule allows 5 new connections per minute, if you exceed this limit, your new connections will be rejected after some time has passed:

-A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -m limit --limit 5/min -j ACCEPT

See the IPTables / Netfilter documentation, scroll a bit till limit.

share|improve this answer
add comment

It's basically because of any one of the following reasons:

  1. Too many users on the network trying to access the server
  2. More than one computer on the network has the same IP as the server causing an IP conflict
  3. Wrong username or your credentials have been revoked
share|improve this answer
add comment

protected by Community Jan 8 at 18:47

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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