1

我试图在运行 Linux Fedora 18 的机器上设置 svn。我使用 htpasswd 创建并添加了新用户。所以基本上我所做的是:

$ htpasswd -c passwd admin. 

其中 passwd 是包含用户名/密码对的文件。默认情况下,htpasswd 应该使用 md5 来加密密码。因此,后来当我尝试登录时,即使我提供了正确的用户名和密码,我也无法登录。在尝试了不同的事情之后,我去了一些在线 md5 生成器,输入了相同的密码。结果字符串与 htpasswd 生成的字符串不同。我手动编辑了passwd文件,输入了我从网站上得到的md5密码并成功登录。是htpasswd有问题还是有一些系统设置需要修复?

4

1 回答 1

2

The syntax is

htpasswd -c passwdfile username

or

htpasswd -cb passwdfile username yourpassword

The default hash algorithm is MD5 since version 2.2.18 of apache (you can identify it by the $apr1$ prefix). Before that, the default hash was unix crypt, (without a prefix). If your apache version is <2.2.18, you'd better force md5 with

htpasswd -cm passwdfile username
htpasswd -cbm passwdfile username yourpassword

Maybe after that you should check your passwdfile is correctly created (do you havec permissions etc).

When you generate an MD5 hash, with online tools or with the htpasswd command-line, it's different each time because it uses a random salt.

于 2013-07-31T07:52:00.053 回答