Linux: Regenerate sshd host keys

Hi,

to generate sshd host keys, for example in case of cloning a virtual linux instance, do the following steps:

Checkout the key file names

root@debdevt:~# grep HostKey /etc/ssh/sshd_config
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key


and generate new keys without a passphrase and a 4096Bit key

root@debdevt:~# ssh-keygen -b 4096 -f /etc/ssh/ssh_host_rsa_key -t rsa -N ""
root@debdevt:~# ssh-keygen -b 4096 -f /etc/ssh/ssh_host_dsa_key -t dsa -N ""
root@debdevt:~# ssh-keygen -b 4096 -f /etc/ssh/ssh_host_ecdsa_key -t ecdsa -N ""
root@debdevt:~# ssh-keygen -b 4096 -f /etc/ssh/ssh_host_ed25519_key -t ed25519 -N ""

Last step. Ensure that only root have access to the key files

root@debdevt:~# chmod 600 /etc/ssh/ssh_host_*_key

Michael

Advertisment to support michlstechblog.info

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress