Created
October 29, 2015 16:25
-
-
Save cGuille/a4b90099f15b17108532 to your computer and use it in GitHub Desktop.
A ssha_passwd bash function you can use to generate passwords hashed with the salted SHA method. You can use the result in an nginx htpasswd file.
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
| function ssha_passwd() { | |
| local clear_pass | |
| read -sp 'Password: ' clear_pass | |
| local salt="$(openssl rand -base64 3)" | |
| local ssha_pass=$(printf "${clear_pass}${salt}" |openssl dgst -binary -sha1 |sed 's#$#'"${salt}"'#' |base64); | |
| echo "{SSHA}$ssha_pass" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment