What should I do if I forget the password created by htpasswd?


 Answer: No way.

The algorithm for .htpasswd is HASHES ( https://en.wikipedia.org/wiki/Hash_function ), the hash is designed to be undecipherable. Therefore, there is no way (unless you brute force for a while) to get the password from the .htpasswd file.
What you need to do is apply the same hashing algorithm to the password given to you and compare it to the hash in the .htpasswd file. If the user and hash are the same, then you're good to go.

So, just re-create a password.

usage:

htpasswd -c /etc/nginx/conf/htpasswd  username

Add a user based on the original user:

htpasswd -b /etc/nginx/conf/htpasswd username2 1234565

Delete a user and password:

htpasswd -D /application/nginx/conf/htpasswd username3

How to change the password?
htpasswd does not have a function to directly modify the password. You need to use the htpasswd delete command to delete the specified user, and then use the htpasswd add user command to create a user to achieve the function of modifying the password.

htpasswd -D /application/nginx/conf/htpasswd username3
htpasswd -b /application/nginx/conf/htpasswd username3 1234565

Post a Comment

Previous Post Next Post