Created
July 1, 2020 09:23
-
-
Save stbuehler/d2725d4e4291227b944d51d7dcd68a99 to your computer and use it in GitHub Desktop.
create ldap {SSHA} (salted sha1) password hashes
This file contains hidden or 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 | |
tmpdir=$(mktemp --tmpdir -d create-ldap-ssha-XXXXXXX) | |
trap 'rm -rf "${tmpdir}"' EXIT | |
openssl rand -out "${tmpdir}/salt" 8 | |
echo -n "Enter password: " | |
read -rs password | |
echo | |
echo -n "Confirm password: " | |
read -rs password2 | |
echo | |
if [ "${password}" != "${password2}" ]; then | |
echo >&2 "Password mismatch" | |
exit 1 | |
fi | |
hash=`(printf '%s' "${password}"; cat "${tmpdir}/salt") | (openssl sha1 -binary; cat "${tmpdir}/salt") | base64` | |
printf '{SSHA}%s\n' "${hash}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment