Skip to content

Instantly share code, notes, and snippets.

@Ham5ter
Last active August 2, 2016 13:11
Show Gist options
  • Save Ham5ter/9e99430088f1c476a67ae864d13957cc to your computer and use it in GitHub Desktop.
Save Ham5ter/9e99430088f1c476a67ae864d13957cc to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# This Script sets a random root password, disables the root user and deletes itself afterwards!
# Put this Script in the "/etc/rc5.d/" directory.
#
# Version: 1.0
# Author: [email protected]
# Date 02.08.2016
genpasswd() {
local l=$1
[ "$l" == "" ] && l=16
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
echo "root:$(genpasswd 64)" | chpasswd
passwd -l root
# Delete the Script itself!
/bin/rm $0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment