Skip to content

Instantly share code, notes, and snippets.

@Ham5ter
Last active October 9, 2022 15:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ham5ter/6cf693f67a1792b55f294969647a4e6a to your computer and use it in GitHub Desktop.
Save Ham5ter/6cf693f67a1792b55f294969647a4e6a to your computer and use it in GitHub Desktop.
regenerate openssh-keys on first boot!
#!/bin/bash
#
# This Script Regenerates the OpenSSH Host Keys, and deletes itself afterwards!
# Put this Script in the "/etc/rc5.d/" directory.
#
# Version: 1.1
# Author: ham5ter@ham5ter.de
# Date 02.08.2016
# SPDX-License-Identifier: MIT
echo "Deletes the old SSH Host Keys!"
/bin/rm -fv /etc/ssh/ssh_host_*
echo "Regenerating the SSH Host Keys!"
dpkg-reconfigure openssh-server
# Delete the Script itself!
/bin/rm "$0"
@stewdk
Copy link

stewdk commented Dec 19, 2019

Are you willing to add an open source license to this?
May I suggest adding this line to the script:
# SPDX-License-Identifier: MIT

@KeyboardInterrupt
Copy link

I updated the License, as you suggested (ham5ter here.),
Also I quote the $0 on Line 17, which in some cases might have been problematic otherwise ^^.
https://gist.github.com/Ham5ter/6cf693f67a1792b55f294969647a4e6a/revisions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment