帮助使用 setspn 和 ktpass

帮助使用 setspn 和 ktpass

我正在尝试设置 SPN 并为 tomcat kerberos spnego 单点登录创建一个密钥表文件。

运行 tomcat7 的服务器是 ubuntu-ad1.wad.eng.hytrst.com KDC 是 kerberos.wad.eng.hytrust.com 域名是 WAD.ENG.HYTRUST.COM 我使用我的广告用户名[电子邮件保护] 该机器的 AD 帐户是[电子邮件保护]

首先,我创建 spn 来与用户名关联(想知道为什么我需要这样做吗?):

setspn HTTP/ubuntu-ad.wad.eng.hytrust.com [email protected]

然后我创建一个 keytab 并将其复制到 Web 服务器:

ktpass /out tomcat.keytab /mapuser [email protected] /crypto ALL /pass * /ptype KRB5_NT_PRINCIPAL 

然后我将其复制到 Web 服务器并将ktutil其与 /etc/krb5.keytab 合并。

当我尝试使用 kinit 测试它时,我无法使其成功从密钥表中读取:

hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab http/[email protected]
kinit: Client not found in Kerberos database while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab HTTP/[email protected]
kinit: Client not found in Kerberos database while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab [email protected]
kinit: Client not found in Kerberos database while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab ubuntu-ad1.wad.eng.hytrust.com
kinit: Client not found in Kerberos database while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab [email protected]
kinit: Key table entry not found while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab [email protected]
kinit: Client not found in Kerberos database while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit  [email protected] for [email protected]: 
kinit: Preauthentication failed while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit  [email protected]

密码[电子邮件保护]: hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$

“Kerberos 数据库中未找到客户端”与“Kerberos 数据库中未找到客户端”有何不同?这些错误到底意味着什么?

答案1

(这个问题有点老了,但我的分析可能会对其他人有所帮助)

您似乎缺乏一些理解,因此无法正确执行命令。我假设您的 KDC 实际上是 Active Directory KDC。从您的描述来看,这一点并不完全清楚。

首先,在 Active Directory Kerberos 中(与标准 MIT/Heimdal Kerberos 相反),服务主体名称 (SPN - 运行机器的服务) 需要连接到用户主体名称 (UPN,位于机器后面的用户)。因此需要映射。

setspn 将通过向用户的 cn 添加 ldap 属性来将服务主体名称添加到用户

ktpass 将输出你的密钥标签将 UserPrincipalName 重写为 username/fully.qualified.domainname@REALM 。

通过执行kinit -k -t key.tab principal查找,将在 key.tab 文件中发生主体上的活动目录 UPN。如果在密钥选项卡中找不到主体,则会给出错误,如“获取初始凭据时未找到密钥表条目”。如果在目录中找不到,则会给出“获取初始凭据时未在 Kerberos 数据库中找到客户端”。

现在来谈谈你手头的问题。看来你缺少 ktpass 的 /princ 参数。这是实际获取密钥选项卡文件中的主体并正确映射所必需的。我想知道 aklist -k keytab给出了什么。

因此您的代码应类似于(包括将 REALM 放在正确的位置):

setspn HTTP/ubuntu-ad.wad.eng.hytrust.com aulfeldt

ktpass /princ HTTP/[email protected] /out tomcat.keytab /mapuser aulfeldt /crypto ALL /pass * /ptype KRB5_NT_PRINCIPAL

额外:如果您使用 SAMBA 4 和 samba-tool 执行此操作,则需要手动将 userPrincipalName 更改为(在本例中):HTTP/[电子邮件保护]这是因为 samba 的密钥标签生成不会更新 UPN,因此您在进行查找时会收到错误。

附注:活动目录机器名称是 COMPUTER$(标记 $)。您的名称似乎不对。

答案2

尝试在 Windows 中使用“setspn -Q”查看 SPN 是否已正确创建:

C:\Windows\System32>setspn -Q HTTP/util01.example.com
CN=util01,OU=Servers,DC=example,DC=com
        HTTP/util01.example.com

Existing SPN found!

然后,检查 keytab 文件是否匹配:

[apache@util01 ~]$ klist -e -k /etc/httpd/conf/auth_httpd.keytab 
Keytab name: FILE:/etc/httpd/conf/auth_httpd.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   3 HTTP/[email protected] (DES cbc mode with RSA-MD5) 

如果它们不匹配(@EXAMPLE.COM 领域位除外),请通过使用 ktpass 重新导出密钥表来修复它。

如果它们确实匹配,您应该能够获得与 keytab 中指定的 SPN 完全匹配的票证(不包括领域):

$ sudo kinit -k keytab.file HTTP/util01.example.com

相关内容