Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to set up a web service (using the Play Framework) on an Ubuntu machine on the network. However, I am experiencing intermittent failures connecting to it, not being able to connect to it far more often than not.

One strange symptom is that these network problems affect SSH as well, and in particular the SSH host key of the machine will change, whether I am connecting to it from another Linux machine or from Windows using PuTTY. One sequence of events seems to be something like:

  • After a while, I am able to SSH into the machine again.
  • I access one page on the web server. It works. I try to access another page. It fails.
  • Shortly thereafter, I am kicked off of my SSH connection.
  • I try to SSH in - the connection can't be established.
  • A while later I try to SSH in - the host key has changed. I accept the change and try to log in but I get "Access denied" in response to my password.
  • A while later, I am able to SSH into the machine again.

And just now I accepted the key change, tried to log on, got disconnected before I could finish typing the password, and reconnected only to see that the key has changed again.

What could be causing the SSH host key to change? If this is a normal feature of the SSH server in response to some sort of strange behaviour, what sort of problems does this imply?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

This is definitely not normal. Given your symptoms, I think you're experiencing an IP address conflict. There are two machines on your network with the same IP address, and one of them is the server you're trying to reach. Sometimes you're reaching the expected machine and all is well. Sometimes you're reaching another machine which has a different SSH key and your connection is rejected.

When there's an IP address conflict, it's common that a router locks in the route to one IP address until a cache expires, then queries the route again and updates it to match whoever responds first, producing somewhat random results. There's nothing preventing the switchover from happenning in the middle of a TCP connection.

Sophisticated routers raise an alert when IP conflicts happen, so your network administrator may already be tracking this. If you're root your server, you can resolve it by picking an unassigned IP address. If you're getting your IP address through DHCP, contact the DHCP administrator.

share|improve this answer
    
Another option is to have a look at the MAC addresses with ip neigh. Does the LL address change when the host key changes? –  Hauke Laging Feb 27 '13 at 2:36
    
@HaukeLaging Indeed, checking the MAC address is a good idea if the client is on the same network segment (which may not be the case). What's LL? –  Gilles Feb 27 '13 at 10:59
    
Sure, ip neigh has to be executed on a system in the same Ethernet segment. On the router, at best, if its another segment. "LL" is "link layer". Sorry, I thought that was common. –  Hauke Laging Feb 27 '13 at 13:08

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.