Browse Source

Add shell helper to generate SSHA http basic auth

Emmanuel Bouthenot 9 years ago
parent
commit
7d48cb8e7d
1 changed files with 12 additions and 0 deletions
  1. 12 0
      .zsh/config/10_alias.zsh

+ 12 - 0
.zsh/config/10_alias.zsh

@@ -145,3 +145,15 @@ if [ -f ~/.ssh/config ]; then
     hosts=($(grep '^Host [^*]' ~/.ssh/config | sed 's/Host //'))
     compctl -k hosts mssh
 fi
+
+#
+# Hosting stuff
+#
+http_auth_ssha() {
+    read "username?username: "
+    read "password?password: "
+    salt="$(openssl rand -base64 3)"
+    sha1="$(printf "%s%s" "${password}" "${salt}" | openssl dgst -binary -sha1 | sed 's#$#'"${salt}"'#' | base64)"
+    printf "%s:{SSHA}%s\n" "${username}" "${sha1}"
+}
+