Skip to content

Instantly share code, notes, and snippets.

@anzz1
Created September 20, 2025 05:28
Show Gist options
  • Select an option

  • Save anzz1/678b9386822b406d664e69c0921a8d9b to your computer and use it in GitHub Desktop.

Select an option

Save anzz1/678b9386822b406d664e69c0921a8d9b to your computer and use it in GitHub Desktop.
htpasswd.sh
#!/bin/sh
# Simple htpasswd replacement using OpenSSL
set -eu
if [ "$#" -ne 2 ]; then
echo "Usage: "$(basename "$0")" <username> <password>" >&2
exit 1
fi
user="$1"
pass="$2"
hash=$(openssl passwd -apr1 "$pass")
echo "${user}:${hash}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment