【问题标题】:does nginx auth_basic send the password plaintext?nginx auth_basic 会发送密码明文吗?
【发布时间】:2016-12-08 04:30:44
【问题描述】:
【问题讨论】:
标签:
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.