htpasswd命令选项参数说明
htpasswd建立和更新存储用户名、密码的文本文件, 用于对HTTP用户的basic认证。
$ sudo apt-get install apache2-utils
# htpasswd -help
htpasswd: illegal option -- h
Usage:
htpasswd [-cimBdpsDv] [-C cost] passwordfile username
htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password
htpasswd -n[imBdps] [-C cost] username
htpasswd -nb[mBdps] [-C cost] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-b Use the password from the command line rather than prompting for it.
-i Read password from stdin without verification (for script usage).
-m Force MD5 encryption of the password (default).
-B Force bcrypt encryption of the password (very secure).
-C Set the computing time used for the bcrypt algorithm
(higher is more secure but slower, default: 5, valid: 4 to 31).
-d Force CRYPT encryption of the password (8 chars max, insecure).
-s Force SHA encryption of the password (insecure).
-p Do not encrypt the password (plaintext, insecure).
-D Delete the specified user.
-v Verify password for the specified user.
On other systems than Windows and NetWare the '-p' flag will probably not work.
The SHA algorithm does not use a salt and is less secure than the MD5 algorithm.
htpasswd常用参数:
-c创建一个加密文件。
-n不更新加密文件,只将htpasswd命令加密后的用户名和密码显示在屏幕上。
-m默认htpassswd命令采用MD5算法对密码进行加密,该参数默认情况下可以不加。
-d表示htpassswd命令采用CRYPT算法对密码进行加密。
-s表示htpassswd命令采用SHA算法对密码进行加密。
-p表示htpassswd命令不对密码进行进行加密,即明文密码。
-b表示在htpassswd命令行中一并输入用户名和密码而不是根据提示输入密码。
-D表示删除指定的用户。
htpasswd常用实例:
1、在/etc/nginx/conf/下生成一个.htpasswd文件,用户名密码为admin、admin1234
htpasswd -cb /etc/nginx/conf/.htpasswd admin admin1234
2、在原有密码文件中增加下一个用户?
htpasswd -b /etc/nginx/conf/.htpasswd zhangsan zs123456
4、利用htpasswd命令删除用户名和密码?
htpasswd -D /etc/nginx/conf/.htpasswd admin
5、如何利用htpasswd命令修改密码?
htpasswd -D .passwd zhangsan
htpasswd -b .passwd lisi lisi8668
需要先利用htpasswd命令删除指定用户,再利用htpasswd添加用户命令创建用户即可实现修改密码的功能。
评论