apache命令htpasswd生成AuthUserFile

转到apache/bin目录下,输入:

htpasswd -cmb user abc 123456

即可在当前目录下生成文件,user,且用户名为abc,密码为123456(加密的),


或依此步骤生成

E:/web/Apache2/bin>htpasswd -c userpass user1
Automatically using MD5 format.
New password: ******
Re-type new password: ******
Adding password for user user1

更新密码:
E:/web/Apache2/bin>htpasswd userpass user1
Automatically using MD5 format.
New password: ******
Re-type new password: ******
Updating password for user user1

添加新用户:
E:/web/Apache2/bin>htpasswd userpass user2
Automatically using MD5 format.
New password: ******
Re-type new password: ******
Updating password for user user2

打开文件userpass,可以看到有两条记录:
user1:$apr1$Rr......$lHobT0z67Sp8heUkS0B.b0
user2:$apr1$Px......$XQWTfGNlfVBgEvQKBK8gt1

删除用户:
htpasswd -D userpass user1
Automatically using MD5 format
Deleting password for user user1
打开文件userpass,可以看到有只一条记录了:
user2:$apr1$Px......$XQWTfGNlfVBgEvQKBK8gt1

 

当然你也可以用些指令生成.htaccess
E:/web/Apache2/bin>htpasswd -c .htaccess user
Automatically using MD5 format.
New password: ******
Re-type new password: ******
Adding password for user user

选项:

 -c  创建新的文件
 -m  用md5方式加密密码
 -b  在命令行上输入密码

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.

E:/web/Apache2/bin>htpasswd -mb user abc 123456
htpasswd: cannot modify file user; use '-c' to create it

E:/web/Apache2/bin>htpasswd -cmb user abc 123456
Adding password for user abc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值