【问题标题】:does nginx auth_basic send the password plaintext?nginx auth_basic 会发送密码明文吗?
【发布时间】:2016-12-08 04:30:44
【问题描述】:

我正在使用这些说明安装 netdata (https://www.digitalocean.com/community/tutorials/how-to-set-up-real-time-performance-monitoring-with-netdata-on-ubuntu-16-04)

最后,它使用htpasswd 创建一个用户:密码文件,该文件看起来像是以某种方式进行了哈希处理。如果我查看我看到的文件...

username:$somekindofpasswordhashandnotthepasswordientered

然后说明告诉我像这样制作一个服务器块......

server {
    listen your_server_ip:80;
    server_name example.com;

    auth_basic "Authentication Required";
    auth_basic_user_file netdata-access; 

netdata-access是nginx conf目录下的密码文件。所以当我访问这个页面并输入密码时,我是通过网络发送我的密码明文,还是 nginx 模块以某种方式对其进行加密?服务器块在端口 80 而不是 443...

编辑:我快速阅读了这两件事的文档,但没有找到关于我的问题的信息

【问题讨论】:

    标签: security encryption nginx .htpasswd


    【解决方案1】:

    auth_basic 工作在连接到服务器时打开的同一个连接上,所以它在http 上是纯文本,在https 上是加密的 SSL/TLS。 user/pass 组合上发生的唯一处理是在发送到服务器之前的Base64 编码。

    您可以使用curl查看标题:

    $ curl -v -u your_user_name "http://......."
    

    查找包含Base64 编码的user:pass> Authorization: Basic ... 行。

    您可以使用以下方法解码字符串:

    printf auth_string | base64 --decode
    

    更多详情here.


    关于密码文件,nginx 可以在密码文件(info here)中使用明文密码和散列密码:

    1.纯文本:

        # comment
        name1:password1
        name2:password2:comment
        name3:password3
    

    2。加密/散列:

    • 使用 crypt() 函数加密;可以使用 Apache HTTP Server 发行版中的“htpasswd”实用程序或
      “openssl passwd”命令;

    • 使用基于 MD5 的密码算法 (apr1) 的 Apache 变体进行散列;可以使用相同的工具生成;

    • RFC 2307 中描述的“{scheme}data”语法(1.0.3+)指定;目前实施的计划包括PLAIN(一个 示例一,不应该使用),SHA(1.3.13)(plain SHA-1 散列,不应使用)和 SSHA(盐渍 SHA-1 散列,使用 通过一些软件包,特别是 OpenLDAP 和 Dovecot)。

    $ htpasswd 
    Usage:
        htpasswd [-cimBdpsDv] [-C cost] passwordfile username
        htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password
    
        htpasswd -n[imBdps] [-C cost] username
        htpasswd -nb[mBdps] [-C cost] username password
     -c  Create a new file.
     -n  Don't update file; display results on stdout.
     -b  Use the password from the command line rather than prompting for it.
     -i  Read password from stdin without verification (for script usage).
     -m  Force MD5 encryption of the password (default).
     -B  Force bcrypt encryption of the password (very secure).
     -C  Set the computing time used for the bcrypt algorithm
         (higher is more secure but slower, default: 5, valid: 4 to 31).
     -d  Force CRYPT encryption of the password (8 chars max, insecure).
     -s  Force SHA encryption of the password (insecure).
     -p  Do not encrypt the password (plaintext, insecure).
     -D  Delete the specified user.
     -v  Verify password for the specified user.
    On other systems than Windows and NetWare the '-p' flag will probably not work.
    The SHA algorithm does not use a salt and is less secure than the MD5 algorithm.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多