nginx auth_basic发送密码明文吗?

del*_*lta 2 security encryption nginx .htpasswd

我正在按照以下说明安装Netdata(https://www.digitalocean.com/community/tutorials/how-to-set-up-real-time-performance-monitoring-with-netdata-on-ubuntu-16-04

到最后,它用于htpasswd创建一个user:password文件,该文件看起来已经以某种方式进行了哈希处理。如果我查看文件,就会看到...

username:$somekindofpasswordhashandnotthepasswordientered
Run Code Online (Sandbox Code Playgroud)

指令然后告诉我制作一个这样的服务器块...

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

    auth_basic "Authentication Required";
    auth_basic_user_file netdata-access; 
Run Code Online (Sandbox Code Playgroud)

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

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

ali*_*ndt 5

auth_basic可以在连接到服务器时打开的同一连接上工作,因此其为纯文本格式,http并为加密SSL / TLS https用户/通行证组合上发生的唯一处理是Base64编码,然后发送到服务器。

您可以curl用来查看标题:

$ curl -v -u your_user_name "http://......."
Run Code Online (Sandbox Code Playgroud)

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

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

printf auth_string | base64 --decode
Run Code Online (Sandbox Code Playgroud)

更多细节在这里


关于密码文件,nginx可以在密码文件中使用明文密码和哈希密码(信息在此处):

1.纯文本:

    # comment
    name1:password1
    name2:password2:comment
    name3:password3
Run Code Online (Sandbox Code Playgroud)

2.加密/散列:

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

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

  • RFC 2307中所述的“ {scheme} data”语法(1.0.3+)指定;当前实施的方案包括一些软件包使用的PLAIN(不应该使用示例1),SHA(1.3.13)(不应该使用普通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.
Run Code Online (Sandbox Code Playgroud)