您可以使用curl
看标题:
$ curl -v -u your_user_name "http://......."
外观为> Authorization: Basic ...
线,包含Base64
编码user:pass
。
可以使用解码字符串:
printf auth_string | base64 --decode
更多细节here。
此外,确保/etc/nginx/.htpasswd
有正确的权限为nginx
能够读取它,它包含了您的用户名/密码凭证由nginx
(info here)识别的格式:
1。纯文本:
# comment
name1:password1
name2:password2:comment
name3:password3
2.加密/散列:
加密与隐窝()函数;可以使用Apache HTTP Server发行版中的“htpasswd”实用程序或“openssl passwd”命令生成。
与基于MD5的密码算法(apr1)的Apache变体进行哈希处理;可以使用相同的工具生成;
由“{scheme} data”语法(1.0.3+)指定,如RFC 2307中所述;目前实施的方案包括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.