我遇到问题,因为每次重新启动 Debian 8 都会生成新的主机 RSA 密钥。如何避免这种情况?
答案1
好吧,我知道为什么会这样。在 /etc/rc.local 中有脚本:
#!/bin/sh
rm -f etc/ssh/ssh_host_*
/usr/bin/ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key
/usr/bin/ssh-keygen -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key
/usr/bin/ssh-keygen -t rsa1 -N '' -f /etc/ssh/ssh_host_key
/usr/bin/ssh-keygen -t ecdsa -N '' -f /etc/ssh/ssh_host_ecdsa_key
/usr/bin/ssh-keygen -t ed25519 -N '' -f /etc/ssh/ssh_host_ed25519_key
systemctl restart ssh
DHCP6CCTLKEY=/etc/wide-dhcpv6/dhcp6cctlkey
# The key mustn\'t be world readable
umask 066
echo "Generating ${DHCP6CCTLKEY}..." >&2
dd if=/dev/random bs=32 count=1 2>/dev/null | uuencode -m ${DHCP6CCTLKEY} | head -n 2 | tail -n 1 > ${DHCP6CCTLKEY}
umask 022
mv -f /etc/rc.local.orig /etc/rc.local