Created
April 3, 2013 18:30
-
-
Save treehouse-su/5303845 to your computer and use it in GitHub Desktop.
regenerate_ssh_host_keys
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)" | |
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 && \ | |
update-rc.d ssh enable && sync && \ | |
rm /etc/init.d/regenerate_ssh_host_keys && \ | |
update-rc.d regenerate_ssh_host_keys remove && \ | |
printf '\nfinished\n' && invoke-rc.d ssh start" > /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