Created
February 24, 2015 23:39
-
-
Save kjoconnor/507034975dbcc7b6226b to your computer and use it in GitHub Desktop.
Generate SHA512 passwords for /etc/shadow
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 | |
type -P chpasswd 2>&1 > /dev/null | |
if [ $? -ne 0 ]; then | |
echo "chpasswd not available" | |
exit 1 | |
fi | |
read -p "Username: " USERNAME | |
echo -n "Password: " | |
read -s PASSWORD1 | |
echo "" | |
echo -n "Verify password: " | |
read -s PASSWORD2 | |
echo "" | |
if [ "a${PASSWORD1}" != "a${PASSWORD2}" ]; then | |
echo "Passwords do not match." | |
exit 2 | |
else | |
echo "${USERNAME}:${PASSWORD1}" | chpasswd -S -c SHA512 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment