htpasswd建立和更新存储用户名、密码的文本文件, 用于对HTTP用户的basic认证。
[root@localhost www]# htpasswd --help 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 创建passwdfile.如果passwdfile 已经存在,那么它会重新写入并删去原有内容. -n 不更新passwordfile,直接显示密码 -m 使用MD5加密(默认) -d 使用CRYPT加密(默认) -p 使用普通文本格式的密码 -s 使用SHA加密 -b 命令行中一并输入用户名和密码而不是根据提示输入密码,可以看见明文,不需要交互 -D 删除指定的用户
1.生成加密密码文件
htpasswd -c .htpass htuser New password: Re-type new password: Adding password for user htuser
生成md5加密密码文件,且直接在命令行输入密码
htpasswd -cmb .htpass htuser htpass Adding password for user htuser
2.修改密码
htpasswd .htpass htuser New password: Re-type new password: Updating password for user htuser
3.删除用户
htpasswd -D .htpass htuser Deleting password for user htuser
Apache配置
AllowOverride All
.htaccess配置
AuthType "Basic" AuthName "Password Required" AuthUserFile "/xxx/xxx/.htpass" Require valid-user
本文链接:https://jeff.xin/post/89.html
--EOF--
发表于 2018-02-11 ,并被添加「 Apache 」标签 。
Comments
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。