Skip to main content

Regenerating SSH Host Keys

If you need to regenerate the SSH Host keys on a system, such as after you clone an Linux system and want to make the new clone unique, you can use the following commands to regenerate the system SSH host keys.

Remove Current SSH Host Keys
#Remove current SSH Host Keys
sudo /bin/rm -v /etc/ssh/ssh_host_*

Screenshot 2022-11-01 004624.png

Regenerate SSH Host Keys
#Regenerate SSH Host Keys
sudo dpkg-reconfigure openssh-server

Screenshot 2022-11-01 004646.png

The next time you SSH into the machine, you will see that it is presenting to you a different host key.

Screenshot 2022-11-01 004851.png