htpasswd命令
来源:原创 更新时间:2018-09-05 21:52:01 作者:管理员 浏览:1705
- 命令描述
- 命令语法
- 命令选项
//创建一个新的文件
-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).
//从stdin读取密码而不进行验证(用于脚本)
-m Force MD5 encryption of the password (default).
//使用md5加密(默认)
-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.
- 命令实例
实例1:
创建一个新的文件,并设置密码和用户,交互式
[root@test ~]# htpasswd -c /tmp/htpasswd linux New password: Re-type new password: Adding password for user linux [root@test ~]# cat /tmp/htpasswd linux:$apr1$3VhLd1HR$uSkhBgwIGYFDY5lWzZZsM0
实例2:
添加一个新用户到配置文件中,非交互式创建密码
[root@test ~]# htpasswd -b /tmp/htpasswd baodian 321 Adding password for user baodian [root@test ~]# cat /tmp/htpasswd linux:$apr1$3VhLd1HR$uSkhBgwIGYFDY5lWzZZsM0 baodian:$apr1$ApIm66k6$CpqxwyqMUq.ZbcmMVELu10
实例3:
删除一个指定的用户
[root@test ~]# htpasswd -D /tmp/htpasswd linux Deleting password for user linux [root@test ~]# cat /tmp/htpasswd baodian:$apr1$ApIm66k6$CpqxwyqMUq.ZbcmMVELu10
从指定的文件里面删除指定的用户