Created
May 2, 2017 20:58
-
-
Save davinkevin/135d39954c2730bafa1a4222d98545c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: regenerate_ssh_host_keys | |
# Required-Start: | |
# Required-Stop: | |
# Default-Start: 2 | |
# Default-Stop: | |
# Short-Description: Regenerate ssh host keys | |
# Description: | |
### END INIT INFO | |
. /lib/lsb/init-functions | |
set -e | |
case "$1" in | |
start) | |
log_daemon_msg "Regenerating ssh host keys (in background)" | |
modprobe -q bcm2708-rng && dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096 2>/dev/null | |
nohup sh -c "yes | ssh-keygen -q -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key && \ | |
yes | ssh-keygen -q -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key && \ | |
yes | ssh-keygen -q -N '' -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key && \ | |
yes | ssh-keygen -q -N '' -t ed25519 -f /etc/ssh/ssh_host_ed25519_key && \ | |
systemctl enable ssh && sync && \ | |
rm /etc/init.d/regenerate_ssh_host_keys && \ | |
update-rc.d regenerate_ssh_host_keys remove && \ | |
printf '\nfinished\n' && systemctl start ssh" > /var/log/regen_ssh_keys.log 2>&1 & | |
log_end_msg $? | |
;; | |
*) | |
echo "Usage: $0 start" >&2 | |
exit 3 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment