尝试将我的 OpenLDAP 配置为使用 SASL/GSSAPI (kerberos) 身份验证。我的 KDC 服务器已启动并正在运行,我能够创建所有主体和 SPN,并且可以很好地进行 kinit。
但是当尝试时
ldapsearch -LLL -Y GSSAPI -H ldap://ldap -s "base" -b "dc=example,dc=com"
它失败了:
SASL/GSSAPI authentication started
ldap_sasl_interactive_bind: Invalid credentials (49)
additional info: SASL(-13): authentication failure: GSSAPI Failure: gss_accept_sec_context
OpenLDAP 使用默认的密钥表位置,密钥表内容:
Keytab name: FILE:/etc/krb5.keytab
KVNO Timestamp Principal
---- ----------------- --------------------------------------------------------
0 04/03/24 03:14:34 ldap/[email protected]
0 04/03/24 03:14:34 ldap/[email protected]
我的票证缓存有一个正确的用户,user1
/ # klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: [email protected]
Valid starting Expires Service principal
04/03/24 04:04:57 04/03/24 16:04:57 krbtgt/[email protected]
renew until 04/10/24 04:04:55
我错过了什么?
已解决!
为了从错误中获取更多信息,我重新启动了 OpenLDAP,并使用 -d 1 标志启用了调试。
/usr/sbin/slapd -h "ldap:/// ldapi:///" -d 1
然后再次尝试使用 GSSAPI 进行 ldapsearch,现在 OpenLDAP 调试给了我答案
根本问题:
SASL [conn=1000] Failure: GSSAPI Error: Miscellaneous failure (see text) (Failed to find ldap/[email protected](kvno 1) in keytab FILE:/etc/krb5.keytab (aes256-cts-hmac-sha1-96))
我在 keytab 文件中有
ldap/[email protected]
,但我错误地将 kvno 设置为 0,而我应该将其设置为 1。
使用 kvno 1 再次将
ldap/[email protected]
添加到密钥表后,我的 GSSAPI 身份验证按预期工作!
/ # ldapsearch -LLL -Y GSSAPI -H ldap://ldap -s "base" -b "dc=example,dc=com"
SASL/GSSAPI authentication started
SASL username: [email protected]
SASL SSF: 56
SASL data security layer installed.
dn: dc=example,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: exmaple.com
dc: example