我有一个使用 Apache 在 Linux 计算机上运行的网站。我已使用 mod_auth_kerb 针对 Windows Active Directory 服务器进行单点登录 Kerberos 身份验证。
为了使 Kerberos 正常工作,我在 Active Directory 中创建了一个名为 的服务帐户dummy
。
我使用以下命令在 Windows AD 服务器上使用 ktpass.exe 为 Linux Web 服务器生成了一个密钥表:
ktpass /out C:\krb5.keytab /princ HTTP/[email protected] /mapuser [email protected] /crypto RC4-HMAC-NT /ptype KRB5_NT_PRINCIPAL /pass xxxxxxxxx
我可以使用以下命令从 Linux Web 服务器成功获取票证:
kinit -k -t /path/to/keytab HTTP/[email protected]
... 并使用 查看票证klist
。
我还用以下 Kerberos 属性配置了我的 Web 服务器:
<Directory />
AuthType Kerberos
AuthName "Example.com Kerberos domain"
KrbMethodK5Passwd Off
KrbAuthRealms EXAMPLE.COM
KrbServiceName HTTP/[email protected]
Krb5KeyTab /path/to/keytab
Require valid-user
SSLRequireSSL
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
但是,当我尝试登录网站时(从另一个桌面登录,用户名为“Jeff”),Web 服务器不会自动接受我的 Kerberos 凭据。它应该在那之后立即授予我访问权限,但事实并非如此。我从 mod_auth_kerb 日志中获得的唯一信息是:
kerb_authenticate_user entered with user (NULL) and auth_type Kerberos
但是,当我将 mod_auth_kerb 设置更改KrbMethodK5Passwd
为On
:时,会显示更多信息:
[Fri Oct 18 17:26:44 2013] [debug] src/mod_auth_kerb.c(1939): [client xxx.xxx.xxx.xxx] kerb_authenticate_user entered with user (NULL) and auth_type Kerberos
[Fri Oct 18 17:26:44 2013] [debug] src/mod_auth_kerb.c(1031): [client xxx.xxx.xxx.xxx] Using HTTP/[email protected] as server principal for password verification
[Fri Oct 18 17:26:44 2013] [debug] src/mod_auth_kerb.c(735): [client xxx.xxx.xxx.xxx] Trying to get TGT for user [email protected]
[Fri Oct 18 17:26:44 2013] [debug] src/mod_auth_kerb.c(645): [client xxx.xxx.xxx.xxx] Trying to verify authenticity of KDC using principal HTTP/[email protected]
[Fri Oct 18 17:26:44 2013] [debug] src/mod_auth_kerb.c(1110): [client xxx.xxx.xxx.xxx] kerb_authenticate_user_krb5pwd ret=0 [email protected] authtype=Basic
我遗漏了什么?我研究了很多在线教程,但找不到 Kerberos 凭据不允许访问的原因。
答案1
在查阅了大量日志信息后,我发现客户端计算机没有正确响应服务器的票据。您可以通过以下方式判断客户端计算机出了问题:您将看到 Apache 服务器的错误消息“无法验证 krb5 凭据:Kerberos 数据库中未找到服务器“。在/etc/krb5.conf
客户端计算机上的文件中,您必须确保 Web 域名映射到正确的 Kerberos 领域:
[domain_realm]
example.com = REALM.EXAMPLE.COM
.example.com = REALM.EXAMPLE.COM
如果没有这个,客户端将拒绝服务器,因为Kerberos 票证只能来自明确允许的领域。
我希望这些信息能帮助到其他人!