How to automate generation of htpasswd from command line without typing password?

Tampa picture Tampa · Apr 15, 2012 · Viewed 21.6k times · Source

I am trying to automate creating a password from the command line. I have tried the below but it still keeps asking for the password.

echo "test101" | htpasswd -c ~/temp/password admin

How to generate automate htpasswd from command line without typing password?

Answer

GavinCattell picture GavinCattell · Apr 15, 2012

Why not just use:

htpasswd -b -c ~/temp/password admin test101