本帖最后由 wsw13640218682 于 2016-1-14 23:10 编辑
1、下载passwd.py工具并存放到指定路径
我就存放到/root/shell
[root@user13 ~]# ls shell/
htpasswd.py
# cd /root/shell
# wget http://trac.edgewall.org/export/10770/trunk/contrib/htpasswd.py
需要更改此文件的权限:
# chmod 700 htpasswd.py
2、查看此工具的使用说明
使用非常简单:
# ./htpasswd.py -h
Usage: htpasswd.py [-c] -b filename username password
Create or update an htpasswd file
Options:
-h, --help show this help message and exit
-b Batch mode; password is passed on the command line IN THE CLEAR.(再添加新用户和密码)
-c Create a new htpasswd file, overwriting any existing file. (添加新的用户不要用这个参数)
-D Remove the given user from the password file.
3、创建.htpasswd文件同时创建用户user1
# ./htpasswd.py -c /usr/local/nginx/conf/.htpasswd -b user1 123456
# cat /usr/local/nginx/conf/.htpasswd
# ./htpasswd.py -b /usr/local/nginx/conf/.htpasswd user2 123456
# cat /usr/local/nginx/conf/.htpasswd
user1:jbAcldPn0ogKo
user2:DlCozcdYdGCCA
删除用户user2
# ./htpasswd.py -D -b /usr/local/nginx/conf/.htpasswd user2
# cat /usr/local/nginx/conf/.htpasswd
user1:jbAcldPn0ogKo
nginx对某个站点或者某个目录进行登录认证时,我们会使用htpasswd程序去创建用户及用户认证文件,此程序只有安装了apache后才能使用,如果我们不想安装apache时,如果生成此文件及对用户进行管理,这里介绍一个非常适用工具htpasswd.py.
如果没有安装apache我们可以利用htpasswd.py来生成及管理htpasswd文件1、下载passwd.py工具并存放到指定路径
我就存放到/root/shell
[root@user13 ~]# ls shell/
htpasswd.py
# cd /root/shell
# wget http://trac.edgewall.org/export/10770/trunk/contrib/htpasswd.py
需要更改此文件的权限:
# chmod 700 htpasswd.py
2、查看此工具的使用说明
使用非常简单:
# ./htpasswd.py -h
Usage: htpasswd.py [-c] -b filename username password
Create or update an htpasswd file
Options:
-h, --help show this help message and exit
-b Batch mode; password is passed on the command line IN THE CLEAR.(再添加新用户和密码)
-c Create a new htpasswd file, overwriting any existing file. (添加新的用户不要用这个参数)
-D Remove the given user from the password file.
3、创建.htpasswd文件同时创建用户user1
# ./htpasswd.py -c /usr/local/nginx/conf/.htpasswd -b user1 123456
# cat /usr/local/nginx/conf/.htpasswd
user1:jbAcldPn0ogKo
创建用户user2# ./htpasswd.py -b /usr/local/nginx/conf/.htpasswd user2 123456
# cat /usr/local/nginx/conf/.htpasswd
user1:jbAcldPn0ogKo
user2:DlCozcdYdGCCA
删除用户user2
# ./htpasswd.py -D -b /usr/local/nginx/conf/.htpasswd user2
# cat /usr/local/nginx/conf/.htpasswd
user1:jbAcldPn0ogKo
0
你错了,不需要安装apache
安装httpd-tools 就可以啦
yum install -y httpd-tools
不需要安装整个apache
httpd-tools里面已经包含htpasswd和ab压力测试工具
安装httpd-tools 就可以啦
yum install -y httpd-tools
不需要安装整个apache
httpd-tools里面已经包含htpasswd和ab压力测试工具
0
{:7_229:}你说的对...
lyhabc 发表于 2016-1-15 08:21
你错了,不需要安装apache
安装httpd-tools 就可以啦
yum install -y httpd-tools
{:7_229:}你说的对...
编辑回复