一、 基础


htpasswd建立和更新存储用户名、密码的文本文件, 用于对HTTP用户的basic认证。

# /usr/local/apache/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 other systems than Windows, NetWare and TPF 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 删除指定的用户

三、实例


  • 如何利用htpasswd命令添加用户?

    # /usr/local/apache/bin/htpasswd -bc linuxeye_pd linuxeye_user linuxeye_password

    Adding password for user linuxeye_user

    # cat linuxeye_pd

    linuxeye_user:Mugpp3FE$zGsi7/JfQIhFXPlgqo/Wx/

    生成当前目录下生成一个linuxeye_pd文件,用户名linuxeye_user,密码:linuxeye_password,默认采用MD5加密方式

  • 如何在原有密码文件中增加下一个用户?

    # /usr/local/apache/bin/htpasswd -b linuxeye_pd linuxeye.com linuxeye.com

    Adding password for user linuxeye.com

    # cat linuxeye_pd

    linuxeye_user:Mugpp3FEapr14MBxYpzotrSDcTTDZvTeT0

    一定要去掉-c选项,否则覆盖密码文件再创建

  • 如何不更新密码文件,只显示加密后的用户名和密码?

    # /usr/local/apache/bin/htpasswd -n linuxeye

    New password:

    Re-type new password:

    linuxeye:bZ6Gclc4$zKRap.0BADzZIxLoxpDNv0

    # /usr/local/apache/bin/htpasswd -nb linuxeye linuxeye_password

    linuxeye:$apr1$yvngdKGV$QrnlriJ.MxIu52Vmo.ROE1

  • 如何利用htpasswd命令删除用户名和密码?

    # /usr/local/apache/bin/htpasswd -D linuxeye_pd linuxeye_user

    Deleting password for user linuxeye_user

    # cat linuxeye_pd

    linuxeye.com:/8EUOPYI$4MBxYpzotrSDcTTDZvTeT0

  • 如何利用htpasswd命令修改密码?

    # /usr/local/apache/bin/htpasswd -D linuxeye_pd linuxeye.com

    Deleting password for user linuxeye.com

    # /usr/local/apache/bin/htpasswd -b linuxeye_pd linuxeye.com linuxeye_passwd

    Adding password for user linuxeye.com

    # cat linuxeye_pd

    linuxeye.com:74ZvB1vC$/b7ETmg8xhDPieYj0b0cE.

    需要先利用htpasswd命令删除指定用户,再利用htpasswd添加用户命令创建用户即可实现修改密码的功能。

Apache htpasswd命令用法详解的更多相关文章

  1. lsof 命令用法详解

    lsof 命令用法详解 作用 用于查看你进程开打的文件,打开文件的进程,进程打开的端口(TCP.UDP).找回/恢复删除的文件.是十分方便的系统监视工具,因为lsof命令需要访问核心内存和各种文件,所 ...

  2. systemctl命令用法详解

    systemctl命令用法详解系统环境:Fedora 16binpath:/bin/systemctlpackage:systemd-units systemctl enable httpd.serv ...

  3. Ubuntu kill命令用法详解

    转自:Ubuntu kill命令用法详解 1. kill   作用:根据进程号杀死进程   用法: kill [信号代码] 进程ID   root@fcola:/# ps -ef | grep sen ...

  4. install 命令用法详解

    install 命令用法详解 http://man.linuxde.net/install install命令的作用是安装或升级软件或备份数据,它的使用权限是所有用户.install命令和cp命令类似 ...

  5. Linux下find命令用法详解

    Linux下find命令用法详解   学神VIP烟火 学神IT教育:XueGod-IT   最负责任的线上直播教育平台   本文作者为VIP学员 烟火   第一部分:根据文件名查找   1.在当前目录 ...

  6. Linux Shell脚本入门--wget 命令用法详解

    Linux Shell脚本入门--wget 命令用法详解 wget是在Linux下开发的开放源代码的软件,作者是Hrvoje Niksic,后来被移植到包括Windows在内的各个平台上.它有以下功能 ...

  7. (转)linux paste命令用法详解

    linux paste命令用法详解原文:http://www.xfcodes.com/linuxcmd/mulu/10211.htmlinux下paste命令,可用于合并文件的列. 功能说明:合并文件 ...

  8. CentOS 7.X 中systemctl命令用法详解

    systemctl是RHEL 7 的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体.可以使用它永久性或只在当前会话中启用/禁用服务,下面来看CentOS 7.X 中 ...

  9. [转帖]强大的strace命令用法详解

    强大的strace命令用法详解 文章转自: https://www.linuxidc.com/Linux/2018-01/150654.htm strace是什么? 按照strace官网的描述, st ...

随机推荐

  1. TCP/IP之大明内阁---协议的制定

    个人感言:真正的知识是深入浅出的,码农翻身" 公共号将苦涩难懂的计算机知识,用形象有趣的生活中实例呈现给我们,让我们更好地理解.感谢"码农翻身" 公共号,感谢你们的成果, ...

  2. C#遍历集合与移除元素的方法

    如果用foreach,会造成被遍历的集合更改后带来异常问题. 此时,用for循环可有效的解决这个问题. for(int i=0;i<List.Count;i++) { if(条件是真) { Li ...

  3. tcp协议头窗口,滑动窗口,流控制,拥塞控制关系

    参考文章 TCP 的那些事儿(下) http://coolshell.cn/articles/11609.html tcp/ip详解--拥塞控制 & 慢启动 快恢复 拥塞避免 http://b ...

  4. java学习第13天( java获取当前时间,有关大数据的运算及精确数字运算,Date类)

    一 java获取当前时间 学习一个函数,得到当前时间的准确值 System.currectTimeMillis(). 可以得到以毫秒为单位的当前时间.它主要用于计算程序运行时间,long start= ...

  5. STL迭代器之二:迭代器型别

    如果一个迭代器要兼容stl,必须遵循约定,自行以内嵌型别定义的方式定义出相应型别.根据书中介绍,最常用到的迭代器型别有五种:value type,difference type, pointer, r ...

  6. 安装zabbix报错configure: error: libcurl library not found

    libcurl 和libcurl-devel都已经安装 且大于7.13.1 但还是报错,这时需要在configure 指定curl路径即可 ./configure --prefix=/usr/loca ...

  7. Verilog $random用法

    “$random函数调用时返回一个32位的随机数,它是一个带符号的整形数...”,并给出了一个例子: _________________________________________________ ...

  8. 将Excel数据导入数据库

    Excel如下,这页工作表名叫“线路” 数据库表如下 using System; using System.Collections.Generic; using System.Linq; using ...

  9. LinQ的查询操作

    LinQ的高级查询:-------------------在car表格进行练习操作: 一.模糊查询:1.在后台代码:(Contains)List<car>list=con.car.wher ...

  10. Hibernate—— 一对多 和 多对多关联关系映射(xml和注解)总结(转载)

    One to Many 映射关系 多对一单向外键关联(XML/Annotation) 一对多单向外键关联(XML/Annotation) 懒加载和积极加载 一对多双向外键关联(XML/Annotati ...