Verify user and password against a file created by htpasswd

pupeno picture pupeno · Jun 10, 2014 · Viewed 19.4k times · Source

Is there a way, from the command line, to check a user and password against a file created by htpasswd, the tool provided by Apache?

Answer

Eren Güven picture Eren Güven · Oct 19, 2016

You can use the htpasswd tool for this.

# create htpasswd_file with user:password
$ htpasswd -cb htpasswd_file user password
Adding password for user user

# verify password for user
$ htpasswd -vb htpasswd_file user wrongpassword
password verification failed

$ htpasswd -vb htpasswd_file user password
Password for user user correct.

Exit status is 0 for success, 3 for failure.