Skip to content

Instantly share code, notes, and snippets.

@cGuille
Created October 29, 2015 16:25
Show Gist options
  • Select an option

  • Save cGuille/a4b90099f15b17108532 to your computer and use it in GitHub Desktop.

Select an option

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.
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