Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a server (lets assume its ip be a.b.c.d) which allows users to login via ssh. Now I want to change the physical machine keeping the ip same. So that the new machine is still accessed by a user like this

$ssh a.b.c.d

Problem is, every time one user tries to login, she gets the following ssh-key mismatch error.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
02:dc:c6:18:1b:34:b7:1d:fa:90:ab:e1:95:48:69:84.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:37
RSA host key for alumni has changed and you have requested strict checking.
Host key verification failed.

I know that user can delete line # 37 from the file ~/.ssh/known_hosts and next time she would get a yes/no prompt. What I want is that user should be kept unaware of this whole machine replacement thing and just get a prompt for password.

How to do that?

share|improve this question
2  
Are you aware that this would defeat ssh's only protection against man in the middle attacks and could result in you sending your password right to the attacker instead of the intended machine? Unless you know for a fact that you are invulnerable to active attacks (for example, you are on the same secure internal network as the target machine) this destroys ssh's security model. –  David Schwartz Jan 10 '13 at 15:25
    
Yes. Both the machines are in the same internal networks. Even the users are inside the same internal network. Given this situation, what are my options? –  Souvik Pal Jan 10 '13 at 16:07
    
That's not enough. They have to be in the same secure internal network. That is, they must absolutely, 100% trust that no device is connected to that internal network that is not 100% secure, and they must 100% trust everyone who has control over those devices or can attach a device to that network. In other words, in almost any realistic scenario, this is a bad idea. –  David Schwartz Jan 10 '13 at 16:53
1  
It's a perfectly reasonable thing to do. I'm replicating the ssh server keys to another server for HA so that when I login I'm getting those errors. Besides I get emailed on failover. –  Matt H Dec 12 '13 at 2:35
add comment

2 Answers

up vote 1 down vote accepted

As Ethabell mentioned, you can copy over the current host keys to the new server.

You can find your host keys by opening your sshd_config file (On my Ubuntu 12.04 box its /etc/ssh/sshd_config). In the config file look for the HostKey entries. These entries will tell you where the host key files are located. You should be able to copy these files to the new server and update the new server's sshd_config to point to the copied keys (or just overwrite the files that already exist on the new server).

Also, note this section from the sshd_config man page, specifically the part about permissions:

Specifies a file containing a private host key used by SSH. The default is /etc/ssh/ssh_host_key for protocol version 1, and /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_ecdsa_key and /etc/ssh/ssh_host_rsa_key for protocol version 2. Note that sshd(8) will refuse to use a file if it is group/world-accessible. It is possible to have multiple host key files. “rsa1” keys are used for version 1 and “dsa”, “ecdsa” or “rsa” are used for version 2 of the SSH protocol.

share|improve this answer
    
Thank you all, this seems to have solved the issue. –  Souvik Pal Jan 10 '13 at 17:00
add comment

If you had the original host key you could restore it and this would stop the error.

Or, you could turn off StrictHostKeyChecking in your sshd config file.

... Doing this, however, is an awful, awful idea. If there is a way for you to just run ssh-keygen -R server.example.com on client machines, that would be the best way -- because turning off host key checking is like saying, "Hey. Attack me." I get wanting obscurity when things change, but security should be priority #1 over obscuring changes.

share|improve this answer
    
Can you elaborate on how to restore host keys on newer machine? –  Souvik Pal Jan 10 '13 at 16:09
add comment

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.