Skip to content

htpasswd

Install

apt install apache2-utils

Basic

NUSER=admin
NPASS=$(</dev/urandom tr -dc 'A-Za-z0-9' | head -c20)
echo -e "---\n[+] NEW password:\n$NUSER:$NPASS"
echo -e "---\n[+] Hashed value:\n---"
htpasswd -bn $NUSER $NPASS

bcrypt

$ htpasswd -b -B -C 10 -n username password
username:$2y$10$7Puxg0ggVVClCfI5sdJx.OdFyuW8GpVyHYwyuOY9J0OkjxOmA63au

admin:password

newpass=password
htpasswd -bc .htpasswd admin $newpass
# cat .htpasswd
admin:$apr1$OB/RXgaZ$e5Wqqg8lvdhkdXMildSUu1

generate-random-value