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 cloned a server and so they've the same RSA key fingerprint.

It seems to be defined in /etc/ssh/ssh_host_rsa_key.pub.

What is the correct way to change that?

Thanks.

share|improve this question

4 Answers 4

up vote 6 down vote accepted

OK found it there: http://www.cyberciti.biz/faq/howto-regenerate-openssh-host-keys/

  1. Delete old ssh host keys: rm /etc/ssh/ssh_host_*
  2. Reconfigure OpenSSH Server: dpkg-reconfigure openssh-server
  3. Update all ssh client(s) ~/.ssh/known_hosts files
share|improve this answer

Or, remove keys and

ssh-keygen -A
share|improve this answer
    
The OP's tags specify debian, but being non platform specific, this answer seems like the better solution. –  mc0e Oct 31 at 14:00
    
Hmm, except it doesn't seem to work for older versions. Eg fails on debian squeeze, which has OpenSSH_5.5p1 –  mc0e Oct 31 at 14:39

For a generic method of doing this:

ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key

ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key

ssh-keygen -q -N "" -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key

mix and match according to the keys your version of OpenSSH supports.

share|improve this answer

Delete them and restart SSHd service. They will be regenerated.

share|improve this answer
1  
No, it doesn't work. /etc/init.d/ssh restart<newline> Could not load host key: /etc/ssh/ssh_host_rsa_key<newline> Could not load host key: /etc/ssh/ssh_host_dsa_key<newline> [....] Restarting OpenBSD Secure Shell server: sshdCould not load host key: /etc/ssh/ssh_host_rsa_key<newline> Could not load host key: /etc/ssh/ssh_host_dsa_key –  Pascal Polleunus Jan 22 '13 at 10:34
    
Indeed. Only works on RHEL based distribs. Sorry –  Heis Spiter Jan 22 '13 at 10:45

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.