zoukankan      html  css  js  c++  java
  • Apache htpasswd命令用法详解

    一、 基础


    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:apr1Mugpp3FE$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:apr1Mugpp3FEzGsi7/JfQIhFXPlgqo/Wx/linuxeye.com:apr1/8EUOPYI4MBxYpzotrSDcTTDZvTeT0
      一定要去掉-c选项,否则覆盖密码文件再创建

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

      # /usr/local/apache/bin/htpasswd -n linuxeye
      New password:
      Re-type new password:
      linuxeye:apr1bZ6Gclc4$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:apr1/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:apr174ZvB1vC$/b7ETmg8xhDPieYj0b0cE.
      需要先利用htpasswd命令删除指定用户,再利用htpasswd添加用户命令创建用户即可实现修改密码的功能。





  • 相关阅读:
    互联网支付的"二清"介绍
    Spring Tool Suite(STS)加速
    如何将任意文件固定在 Win10 的开始屏幕中
    VCL to UniGUI Migration Wizard
    kbmmw 中XML 操作入门(跨平台,而且可以与JSON,YAML,BSON 直接互相转换)
    欧洲历史上“中国热”:一个瓷器可换数个奴隶
    QPointer,QSharedPointer,QWeakPointer的区别与使用例子(QSharedPointer类似Delphi里的引用计数,是强引用,而QWeakPointer是弱引用,不影响原始对象的引用计数,相当于是在暗中观察对象,但保持联系,需要的时候就会出现)
    Visual Studio 2017 for Mac Preview
    NET Core Kestrel部署HTTPS
    多线程
  • 原文地址:https://www.cnblogs.com/snifferhu/p/6148929.html
Copyright © 2011-2022 走看看