欢迎各位兄弟 发布技术文章
这里的技术是共享的
创建.htaccess 文件
AuthType Basic
AuthName "Password Required"
AuthUserFile /var/www/html/keys.txt
Require valid-user
运行命令创建用户登陆文件
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
来自 http://blog.chinaunix.net/uid-366408-id-116448.html
转到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
来自 http://liangchuanfei011.blog.163.com/blog/static/3184295820076316424137/
上一篇文章介绍了如何利用Apache来实现禁止目录访问(禁止游览列出的目录或文件列表)、禁止或允许IP与域名访问目录的方法。其实利用.htaccess和apache htpasswd命令生成经过加密的密码文件对相关目录进行配置,也可以实现对目录的访问权限进行控制,比如登录后台管理目录时输入用户名和密码。今天先分享apache htpasswd命令如何使用,即apache htpasswd命令用法介绍。
1、在apache安装目录bin下找到htpasswd.exe
2、在命令行方式下输入htpasswd -help命令,显示apache htpasswd命令帮助信息,注意需要在htpasswd.exe的当前目录下,即Apache\bin目录下使用htpasswd命令
apache htpasswd命令用法及选项说明
apache htpasswd命令用法
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
apache htpasswd命令选项参数说明
-c
-n
-m
-d
-p
-s
-b
-D
在Windows, NetWare and TPF 系统中 ‘-m’选项是默认的,在使用apache htpasswd命令时可以忽略。在其他系统中,’-p’选项可能不能工作。
apache htpasswd命令用法实例
1、如何利用htpasswd命令添加用户?
htpasswd -bc .passwd www.leapsoul.cn php
在bin目录下生成一个.passwd文件,用户名www.leapsoul.cn,密码:php,默认采用MD5加密方式
2、如何在原有密码文件中增加下一个用户?
htpasswd -b .passwd leapsoul phpdev
去掉c选项,即可在第一个用户之后添加第二个用户,依此类推
3、如何不更新密码文件,只显示加密后的用户名和密码?
htpasswd -nb leapsoul phpdev
不更新.passwd文件,只在屏幕上输出用户名和经过加密后的密码
4、如何利用htpasswd命令删除用户名和密码?
htpasswd -D .passwd leapsoul
5、如何利用htpasswd命令修改密码?
htpasswd -D .passwd leapsoul
htpasswd -b .passwd leapsoul phpdev
即先使用htpasswd删除命令删除指定用户,再利用htpasswd添加用户命令创建用户即可实现修改密码的功能。
至此,apache htpasswd命令的具体介绍和使用方法就介绍完了。
来自 http://blog.sina.com.cn/s/blog_52073c0b01011r1l.html
1、在apache安装目录bin下找到htpasswd.exe
2、在命令行方式下输入htpasswd -help命令,显示apache htpasswd命令帮助信息,注意需要在htpasswd.exe的当前目录下,即Apache\bin目录下使用htpasswd命令
apache htpasswd命令用法及选项说明
apache htpasswd命令用法
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
apache htpasswd命令选项参数说明
-c 创建一个加密文件
-n 不更新加密文件,只将apache htpasswd命令加密后的用户名密码显示在屏幕上
-m 默认apache htpassswd命令采用MD5算法对密码进行加密
-d apache htpassswd命令采用CRYPT算法对密码进行加密
-p apache htpassswd命令不对密码进行进行加密,即明文密码
-s apache htpassswd命令采用SHA算法对密码进行加密
-b 在apache htpassswd命令行中一并输入用户名和密码而不是根据提示输入密码
-D 删除指定的用户
在Windows, NetWare and TPF 系统中 ‘-m’选项是默认的,在使用apache htpasswd命令时可以忽略。在其他系统中,’-p’选项可能不能工作。
apache htpasswd命令用法实例
1、如何利用htpasswd命令添加用户?
htpasswd -bc .passwd www.leapsoul.cn php
在bin目录下生成一个.passwd文件,用户名www.leapsoul.cn,密码:php,默认采用MD5加密方式
2、如何在原有密码文件中增加下一个用户?
htpasswd -b .passwd leapsoul phpdev
去掉c选项,即可在第一个用户之后添加第二个用户,依此类推
3、如何不更新密码文件,只显示加密后的用户名和密码?
htpasswd -nb leapsoul phpdev
不更新.passwd文件,只在屏幕上输出用户名和经过加密后的密码
4、如何利用htpasswd命令删除用户名和密码?
htpasswd -D .passwd leapsoul
5、如何利用htpasswd命令修改密码?
htpasswd -D .passwd leapsoul
htpasswd -b .passwd leapsoul phpdev
即先使用htpasswd删除命令删除指定用户,再利用htpasswd添加用户命令创建用户即可实现修改密码的功能。
至此,apache htpasswd命令的具体介绍和使用方法就介绍完了。
来自 http://blog.163.com/sir_876/blog/static/11705223201023110343769/