Apache htpasswd命令

Apache web server如果使用basic authentication就需要管理password文件,该文件用htpasswd命令管理。这个命令位于$Apache_Home/bin.

具体使用方法可以用 "htpasswd help"来看,打出来的说明如下,

Usage:
        htpasswd [-cmdpsD] passwordfile username
        htpasswd -b[cmdpsD] passwordfile username password
        htpasswd -n[mdps] username
        htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -m  Force MD5 encryption of the password (default).
 -d  Force CRYPT encryption of the password.
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for it.
 -D  Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
常用的命令如下:

htpasswd -bc password jim testpwd

在$Apache_Home/bin下创建password文件,并创建用户jim,密码是testpwd

htpasswd password kay

添加另一个用户kay,会提示输入密码,默认MD5加密

htpasswd -D password kay

删除kay


P.S. Basic authentication的例子:

<Directory "F:\apps\myapp\htdocs">
AuthType Basic
AuthName phpMyAdmin
AuthUserFile "F:\apps\myapp\apache2\users"
Require valid-user
Order allow,deny
Allow from 127.0.0.1
Satisfy all
ErrorDocument 403 /pmaforbidden.html
</Directory>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值