Skip to content

Instantly share code, notes, and snippets.

@kjoconnor
Created February 24, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjoconnor/507034975dbcc7b6226b to your computer and use it in GitHub Desktop.
Save kjoconnor/507034975dbcc7b6226b to your computer and use it in GitHub Desktop.
Generate SHA512 passwords for /etc/shadow
#!/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