在 DNS 域中
domain.local.
有两台机器
host.domain.local. = 192.168.1.1
srv1.domain.local. = 192.168.1.2
host.domain.local. is KDC for Kerberos realm DOMAIN.LOCAL,
srv1.domain.local. is a KDC for Kerberos realm RC.DOMAIN.LOCAL.
RC.DOMAIN.LOCAL 和 DOMAIN.LOCAL 之间存在单向信任:
RC.DOMAIN.LOCAL ===trusts===> tickets from DOMAIN.LOCAL,
但反之则不然。
srv1 上的 RC.DOMAIN.LOCAL 的 KDC 已根据以下说明使用 OpenLDAP 后端进行设置:
http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_ldap.html
其 OpenLDAP 后端位于 host.domain.local,可通过
ldaps://host.domain.local:636.
srv1 上还安装了本地 OpenLDAP(但已禁用),因此 srv1 上存在本地 ldap.conf 等需要考虑。
当我在 (srv1) 根会话中手动启动 srv1 上的 KDC 时
root@srv1:~# krb5kdc
一切正常。
当我尝试通过系统初始化脚本启动 srv1 上的 KDC 时
root@srv1:~# /etc/init.d/krb5-kdc start
或者
root@srv1:~# service krb5-kdc start
srv1 上的 krb5kdc 与主机上的 slapd 之间的 TLS 对话失败;合并的系统日志为
14:46:44 host.domain.local slapd[1778]: daemon: activity on 1 descriptor
14:46:44 host.domain.local slapd[1778]: slap_listener_activate(6):
14:46:44 srv1 krb5kdc[3206]: krb5kdc: cannot initialize realm RC.DOMAIN.LOCAL - see log file for details
14:46:44 host.domain.local slapd[1778]: >>> slap_listener(ldaps://192.168.1.1:636/)
14:46:44 host.domain.local slapd[1778]: daemon: listen=6, new connection on 10
14:46:44 host.domain.local slapd[1778]: daemon: added 10r (active) listener=(nil)
14:46:44 host.domain.local slapd[1778]: conn=1037 fd=10 ACCEPT from IP=192.168.1.2:38664 (IP=192.168.1.1:636)
14:46:44 host.domain.local slapd[1778]: daemon: select: listen=6 active_threads=0 tvp=NULL
14:46:44 host.domain.local slapd[1778]: daemon: select: listen=7 active_threads=0 tvp=NULL
14:46:44 host.domain.local slapd[1778]: daemon: activity on 1 descriptor
14:46:44 host.domain.local slapd[1778]: daemon: waked
14:46:44 host.domain.local slapd[1778]: daemon: select: listen=6 active_threads=0 tvp=NULL
14:46:44 host.domain.local slapd[1778]: daemon: activity on 1 descriptor
14:46:44 host.domain.local slapd[1778]: daemon: activity on:
14:46:44 host.domain.local slapd[1778]: 10r
14:46:44 host.domain.local slapd[1778]:
14:46:44 host.domain.local slapd[1778]: daemon: read activity on 10
14:46:44 host.domain.local slapd[1778]: connection_get(10): got connid=1037
14:46:44 host.domain.local slapd[1778]: connection_read(10): checking for input on id=1037
14:46:44 host.domain.local slapd[1778]: connection_read(10): TLS accept failure error=-1 id=1037, closing
14:46:44 host.domain.local slapd[1778]: connection_closing: readying conn=1037 sd=10 for close
14:46:44 host.domain.local slapd[1778]: connection_close: conn=1037 sd=10
14:46:44 host.domain.local slapd[1778]: daemon: removing 10
14:46:44 host.domain.local slapd[1778]: daemon: activity on 1 descriptor
14:46:44 host.domain.local slapd[1778]: slap_listener_activate(6):
14:46:44 host.domain.local slapd[1778]: >>> slap_listener(ldaps://192.168.1.1:636/)
14:46:44 host.domain.local slapd[1778]: daemon: listen=6, new connection on 10
14:46:44 host.domain.local slapd[1778]: daemon: added 10r (active) listener=(nil)
14:46:44 host.domain.local slapd[1778]: conn=1038 fd=10 ACCEPT from IP=192.168.1.2:38666 (IP=192.168.1.1:636)
14:46:44 host.domain.local slapd[1778]: daemon: select: listen=6 active_threads=0 tvp=NULL
14:46:44 host.domain.local slapd[1778]: daemon: select: listen=7 active_threads=0 tvp=NULL
14:46:44 host.domain.local slapd[1778]: daemon: activity on 1 descriptor
14:46:44 host.domain.local slapd[1778]: daemon: waked
14:46:44 host.domain.local slapd[1778]: daemon: select: listen=6 active_threads=0 tvp=NULL
14:46:44 srv1 systemd[1]: krb5-kdc.service: control process exited, code=exited status=1
14:46:44 srv1 systemd[1]: Failed to start Kerberos 5 Key Distribution Center.
14:46:44 srv1 systemd[1]: Unit krb5-kdc.service entered failed state.
14:46:44 host.domain.local slapd[1778]: daemon: activity on 1 descriptor
14:46:44 host.domain.local slapd[1778]: daemon: activity on:
14:46:44 host.domain.local slapd[1778]: 10r
14:46:44 host.domain.local slapd[1778]:
14:46:44 host.domain.local slapd[1778]: daemon: read activity on 10
14:46:44 host.domain.local slapd[1778]: connection_get(10): got connid=1038
14:46:44 host.domain.local slapd[1778]: connection_read(10): checking for input on id=1038
14:46:44 host.domain.local slapd[1778]: connection_read(10): TLS accept failure error=-1 id=1038, closing
14:46:44 host.domain.local slapd[1778]: connection_closing: readying conn=1038 sd=10 for close
14:46:44 host.domain.local slapd[1778]: connection_close: conn=1038 sd=10
14:46:44 host.domain.local slapd[1778]: daemon: removing 10
srv1 上的 /etc/ldap/ldap.conf 是
rootdn "cn=admin,cn=config"
rootpw {SASL}[email protected]
BASE dc=domain,dc=local
URI ldaps://127.0.0.1:636/ ldapi:///
TLS_CACERT /etc/ldap/ssl/cacert.pem
TLS_REQCERT allow
SASL_MECH EXTERNAL
因此,这主要是指 srv1-local slapd,但就适用而言,在 srv1 上成功手动启动 krb5kdc 时,它会被有效
.ldaprc for root@srv1:
URI ldaps://host.domain.local:636
TLS_REQCERT demand
SASL_MECH EXTERNAL
TLS_CACERT /root/secret/cacert.pem
TLS_CERT /root/secret/root.srv1.domain.local-cert.pem
TLS_KEY /root/secret/private/root.srv1.domain.local-key.pem
以及 srv1 上的 /etc/krb5kdc/kdc.conf 的 dbmodules 部分
[dbmodules]
LDAP = {
db_library = kldap
ldap_kdc_sasl_mech = EXTERNAL
ldap_kdc_dn = cn=krb5kdc,dc=rc,dc=domain,dc=local
ldap_kadmind_dn = cn=kadmind,dc=rc,dc=domain,dc=local
ldap_service_password_file = /etc/krb5kdc/ldap_stash
ldap_kerberos_container_dn = cn=realm,dc=rc,dc=domain,dc=local
#ldap_servers = ldap://host.domain.local:389
ldap_servers = ldaps://host.domain.local:636
}
root@srv1:~# ldapwhoami
产量
SASL/EXTERNAL authentication started
SASL username: cn=root.srv1.domain.local,ou=...
SASL SSF: 0
dn:cn=admin,cn=config
和
root@srv1:~# ldapsearch -b "" -s base -LLL supportedSASLMechanisms
产量
SASL/EXTERNAL authentication started
SASL username: cn=root.srv1.domain.local,ou=...
SASL SSF: 0
dn:
supportedSASLMechanisms: EXTERNAL
srv1 使用 amd64 Debian 8“jessie”运行:
krb5-kdc-ldap 1.12.1+dfsg-19
ldap-utils 2.4.40+dfsg-1+deb8u1
libaprutil1-ldap 1.5.4-1
libkldap4 4:4.14.2-2+b1
libldap-2.4-2 2.4.40+dfsg-1+deb8u1
Debian 兼容的附加 KDC 配置点是 /etc/default/krb5-kdc:
# [...]
DAEMON_ARGS="-r RC.DOMAIN.LOCAL"
# LDAPNOINIT=1
# LDAPRC=.ldaprc
# LDAPTLS_REQCERT=demand
# #LDAPSASL_SECPROPS none
#LDAPSASL_MECH=EXTERNAL
#LDAPTLS_CACERT=/root/secret/cacert.pem
#LDAPTLS_CERT=/root/secret/root.srv1.domain.local-cert.pem
#LDAPTLS_KEY=/root/secret/private/root.srv1.domain.local-key.pem
从中可以看出,我尝试为 KDC 启动脚本手动重建一个合适的 TLS 环境,但仍然无济于事。
那么 - 为什么 KDC 在交互式根 shell 中可以完美运行,但在 init 脚本中却失败了,以及后者该如何处理?
答案1
OpenLDAP 支持的 KDC 似乎只需要位于
在一个有效的SSL 证书目录,
它可以在哪里找到其服务器的密钥和证书,例如/etc/ssl
在我的 srv1 框上;例如,修改 TLS_CACERT 条目
/etc/ldap/ldap.conf
到
#[...]
TLS_CACERT /etc/ssl/certs/cacert.pem
#[...]
使初始化脚本正常运行。
这不是唯一有效的措施,例如,也可以尝试设置
[dbmodules]
LDAP = {
# [...]
ldap_cert_path = ...
# [...]
}
在/etc/krb5kdc/kdc.conf
(未经测试)或添加
LDAPTLS_CACERT=/etc/ssl/certs/cacert.pem
到 Debian /etc/default/krb5-kdc
(已测试)。