X-Git-Url: https://git.cyclocoop.org/?p=lhc%2Fateliers.git;a=blobdiff_plain;f=local%2Fhtpasswd-add;fp=local%2Fhtpasswd-add;h=0438e0a31a0baad52f8474e1b5a006c5d62e6028;hp=0000000000000000000000000000000000000000;hb=41902057ecac8fa4dbe7d140a87ac220e3302bf1;hpb=48df63a68373f2e9025075115d16d3faad474aa9 diff --git a/local/htpasswd-add b/local/htpasswd-add new file mode 100755 index 0000000..0438e0a --- /dev/null +++ b/local/htpasswd-add @@ -0,0 +1,21 @@ +#!/bin/sh -eu +# SYNTAX: $user <$password +tool=$(readlink -e "${0%/*}/..") +. "$tool"/local/lib.sh + +user=$1 +stty -echo +IFS= read -r password +stty echo +salt="$(openssl rand -base64 3)" +sha1=$( + cat <<-EOF | base64 + $(openssl dgst -binary -sha1 <<-EOF + $password$salt + EOF + )$salt + EOF + ) +cat <<-EOF + $user:{SSHA}$sha1 + EOF