Created
January 24, 2012 15:35
-
-
Save phrawzty/1670720 to your computer and use it in GitHub Desktop.
Scipt to generate SHA-512 password fields suitable for /etc/shadow. Requires a relatively recent version of mkpasswd.
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/bash | |
if [ "x$1" == 'x' ]; then | |
echo "USAGE: $0 '<password>'" | |
exit 1 | |
fi | |
# Get an md5sum of the string for eventual extraction. | |
md5=$( echo $1 | md5sum ) | |
extract="${md5:2:8}" | |
mkpasswd -m SHA-512 "$1" "$extract" | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment