Apache 2.4“..身份验证失败..:密码不匹配”

时间:2013-04-01 20:26:26

标签: apache .htaccess authentication .htpasswd

我在Windows Server 2008 R2中运行Apache 2.4。我试图密码保护一个子目录,并成功在Apache 2.0中这样做。升级后,我接受了Apache的建议,并尝试将身份验证配置放在httpd.config中。我允许读取密码文件,一切看起来都是有序的,但是当我测试它时,我收到以下错误:

[Mon Apr 01 19:58:36.438476 2013] [auth_basic:error] [pid 3984:tid 788] [client xxx.yyy.254.2:49253] AH01617:用户主服务器:“/ restricted / file的身份验证失败。 zip“:密码不匹配

但是,我知道我发送了正确的密码。请参阅下面的配置,任何评论都有帮助。

<Directory "C:/www/mydir/restricted">
    #AllowOverride AuthConfig
    #Order allow,deny
    #Allow from all
    AuthType Basic
    AuthName Restricted
    AuthUserFile "C:/www/mydir/passwords/pass"
    Require valid-user
</Directory>  
<Directory "C:/www/mydir">
    Require all granted
</Directory>  
<VirtualHost *:80>
    ServerAdmin admin@.com
    DocumentRoot "C:/www/mydir"
    ServerName "fakeurl.com"
    ErrorLog "C:/www/mydir/logs/error.log"
    CustomLog "C:/www/mydir/logs/accesslog/access.log" common
</VirtualHost>  
<VirtualHost *:80>
    ServerAdmin admin@.com
    DocumentRoot "C:/www/mydir"
    ServerName "www.fakeurl.com"
    ErrorLog "C:/www/mydir/logs/error.log"
    CustomLog "C:/www/mydir/logs/accesslog/access.log" common
</VirtualHost>

3 个答案:

答案 0 :(得分:22)

我刚才有同样的问题,在最后一小时让我疯了。我可以确认Steve建议在命令行中输入密码 - 所以在我的情况下“htpasswd -b passwordfile用户密码”就可以了。

Here是Apache的相关错误报告。

答案 1 :(得分:14)

您是否使用'htpasswd'创建了密码?

httpd-2.4.4中的htpasswd已被破坏(https://issues.apache.org/bugzilla/show_bug.cgi?id=54735)。

根据我的理解,问题是httpd-2.4.4中的htpasswd特有的,并且只有在您手动输入密码时才会出现,因此您可以通过执行以下操作之一来解决此问题:

  • 在命令行上提供密码(例如“htpasswd -b .htpasswd用户密码”);
  • 使用httpd-2.4.3;
  • 中的htpasswd版本
  • 使用摘要式身份验证而不是基本身份验证(htdigest不受影响);
  • 等到httpd-2.4.5发布;
  • 在错误报告中应用补丁(似乎有效)并从源代码重建htpasswd。

答案 2 :(得分:0)

如果您使用Shibboleth,则mod_shib与基本身份验证之间存在冲突。您可以使用以下Apache指令解决此问题:

ShibCompatValidUser On

有关详细信息,请参见Shibboleth on Apache 2.4 Using Mixed Authentication Methods