• Apache htpasswd命令用法详解


    Apache htpasswd命令用法详解

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

    1. # /usr/local/apache/bin/htpasswd --help
    2. Usage:
    3. htpasswd [-cmdpsD] passwordfile username
    4. htpasswd -b[cmdpsD] passwordfile username password
    5. htpasswd -n[mdps] username
    6. htpasswd -nb[mdps] username password
    7. -c Create a new file.
    8. -n Don't update file; display results on stdout.
    9. -m Force MD5 encryption of the password (default).
    10. -d Force CRYPT encryption of the password.
    11. -p Do not encrypt the password (plaintext).
    12. -s Force SHA encryption of the password.
    13. -b Use the password from the command line rather than prompting for it.
    14. -D Delete the specified user.
    15. On other systems than Windows, NetWare and TPF the '-p' flag will probably not work.
    16. The SHA algorithm does not use a salt and is less secure than the MD5 algorithm.

    htpasswd参数

    1. -c 创建passwdfile.如果passwdfile 已经存在,那么它会重新写入并删去原有内容.
    2. -n 不更新passwordfile,直接显示密码
    3. -m 使用MD5加密(默认)
    4. -d 使用CRYPT加密(默认)
    5. -p 使用普通文本格式的密码
    6. -s 使用SHA加密
    7. -b 命令行中一并输入用户名和密码而不是根据提示输入密码,可以看见明文,不需要交互
    8. -D 删除指定的用户

    实例

    1. 如何利用htpasswd命令添加用户?

    1. # /usr/local/apache/bin/htpasswd -bc linuxeye_pd linuxeye_user linuxeye_password
    2. Adding password for user linuxeye_user
    3. # cat linuxeye_pd
    4. linuxeye_user:$apr1$Mugpp3FE$zGsi7/JfQIhFXPlgqo/Wx/

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

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

    1. # /usr/local/apache/bin/htpasswd -b linuxeye_pd linuxeye.com linuxeye.com
    2. Adding password for user linuxeye.com
    3. # cat linuxeye_pd
    4. linuxeye_user:$apr1$Mugpp3FE$zGsi7/JfQIhFXPlgqo/Wx/
    5. linuxeye.com:$apr1$/8EUOPYI$4MBxYpzotrSDcTTDZvTeT0

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

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

    1. # /usr/local/apache/bin/htpasswd -n linuxeye
    2. New password:
    3. Re-type new password:
    4. linuxeye:$apr1$bZ6Gclc4$zKRap.0BADzZIxLoxpDNv0
    5. # /usr/local/apache/bin/htpasswd -nb linuxeye linuxeye_password
    6. linuxeye:$apr1$yvngdKGV$QrnlriJ.MxIu52Vmo.ROE1

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

    1. # /usr/local/apache/bin/htpasswd -D linuxeye_pd linuxeye_user
    2. Deleting password for user linuxeye_user
    3. # cat linuxeye_pd
    4. linuxeye.com:$apr1$/8EUOPYI$4MBxYpzotrSDcTTDZvTeT0

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

    1. # /usr/local/apache/bin/htpasswd -D linuxeye_pd linuxeye.com
    2. Deleting password for user linuxeye.com
    3. # /usr/local/apache/bin/htpasswd -b linuxeye_pd linuxeye.com linuxeye_passwd
    4. Adding password for user linuxeye.com
    5. # cat linuxeye_pd
    6. linuxeye.com:$apr1$74ZvB1vC$/b7ETmg8xhDPieYj0b0cE.

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

    https://linuxeye.com/333.html

    博主QQ 343264992 QQ群交流:100411237 添加时候请备注博客园
  • 相关阅读:
    团队博客18
    团队博客17
    团队博客16
    团队博客15
    团队博客14
    团队博客13
    团队博客12
    课堂作业08--MVC框架的具体应用
    课堂作业07--MVC框架
    课堂作业06--23中设计模式
  • 原文地址:https://www.cnblogs.com/chengkanghua/p/10874541.html
Copyright © 2020-2023  润新知