apache server creates password authentication file
htpasswd command is a built-in tool for Apache's web server, used to create and update password files that store usernames, domains, and user basic authentication.
-c: Create an encrypted file;
-n: Do not update the encrypted file, only display the encrypted username and password on the screen;
-m: By default, the MD5 algorithm is used to encrypt the password;
-d: Use the CRYPT algorithm to encrypt the password;
-p: Do not encrypt the password, that is, plain text password;
-s: Use the SHA algorithm to encrypt the password;
-b: Enter the username and password together in the command line instead of entering the password according to the prompt;
-D: Delete the specified user.
Use htpasswd command to add users
htpasswd -bc .passwd www.jsdig.com php
Generate a .passwd file in the bin directory, with the username www.jsdig.com and password: php. MD5 encryption is used by default.
Add the next user to the original password file
htpasswd -b .passwd Jack 123456
Remove the -c
option to add a second user after the first user, and so on.
Do not update the password file, only display the encrypted username and password
htpasswd -nb Jack 123456
The .passwd file is not updated, and only the username and encrypted password are output on the screen.
Use htpasswd command to delete username and password
htpasswd -D .passwd Jack
Use htpasswd command to change password
htpasswd -D .passwd Jack
htpasswd -b .passwd Jack 123456
That is, first use the htpasswd delete command to delete the specified user, and then use the htpasswd add user command to create the user to realize the function of changing the password.