重置SSH主机密钥
背景
拷贝了linux虚拟机的时候,每台机器的sshd密钥是一样,需要重新生成一下密钥
(密钥的路径配置在sshd的配置文件中,配置项为HostKey,默认值是在/etc/ssh/目录下)
命令
mkdir keys_backup && cp /etc/ssh/ssh_host_* keys_backup/ && rm -f /etc/ssh/ssh_host_*
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ll /etc/ssh/ssh_host_*
systemctl restart sshd
exit