Skip to content

Instantly share code, notes, and snippets.

@levlaz
Created June 1, 2015 16:25
Show Gist options
  • Save levlaz/a3d84f2eacaf52147ce0 to your computer and use it in GitHub Desktop.
Save levlaz/a3d84f2eacaf52147ce0 to your computer and use it in GitHub Desktop.
Regenerate HostKeys
#!/bin/sh
### BEGIN INIT INFO
# Provides: ssh-host-keys
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Regenerates SSH host keys on first boot.
### END INIT INFO
service ssh stop > /dev/null 2>&1
rm -f /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
update-rc.d ssh defaults > /dev/null 2>&1
update-rc.d -f ssh-host-keys remove > /dev/null 2>&1
rm -f /etc/init.d/ssh-host-keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment