Networking HowTos
Networking HowTos

Generate new SSH keys

August 5, 2013 Linux

SSH allows the use of encryption keys to be used to allow logging into a system instead of having to remember a plain text password.
This is great for use in scripts, and automated tasks, but can be a problem is anyone else ever gets the keys somehow.
If the keys become compromised, you must generate new SSH keys.
With the increasing use of virtual servers nowadays, if you are creating new servers based on a image file/backup, you may find the new server has the same keys as the original. You should generate new SSH keys on the new server if that is the case.
Generate new SSH keys:

ssh-keygen -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key

Restart the SSH server for the new keys to take effect.

You Might Also Like