Help using setspn and ktpass

active-directorykerberosspn

I'm trying to set up the SPNs and create a keytab file for tomcat kerberos spnego Single sign on.

the server running tomcat7 is ubuntu-ad1.wad.eng.hytrst.com
the KDC is kerberos.wad.eng.hytrust.com
the domain is WAD.ENG.HYTRUST.COM
im using my ad user name of aulfeldt@WAD.ENG.HYTRUST.COM
the machiene's AD account is ubuntu-ad1@WAD.ENG.HYTRUST.COM

first i create the spn to associate with a user name ( would love an explanation on why I need to do this?):

setspn HTTP/ubuntu-ad.wad.eng.hytrust.com aulfeldt@WAD.ENG.HYTRUST.COM

Then I create a keytab to copy to the web server:

ktpass /out tomcat.keytab /mapuser aulfeldt@WAD.ENG.HYTRUST.COM /crypto ALL /pass * /ptype KRB5_NT_PRINCIPAL 

then i copy it to the web server and use ktutil to merge it with /etc/krb5.keytab.

when I try to test this with kinit i can't make it successfully read from the key table:

hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit -k -t /home/hytrust/tomcat.keytab http/ubuntu-ad1.wad.eng.hytrust.com@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 HTTP/ubuntu-ad1.wad.eng.hytrust.com@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 ubuntu-ad1.wad.eng.hytrust.com@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 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 aulfeldt@WAD.ENG.HYTRUST.COM
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 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  ubuntu-ad1@WAD.ENG.HYTRUST.COMPassword for ubuntu-ad1@WAD.ENG.HYTRUST.COM: 
kinit: Preauthentication failed while getting initial credentials
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$ sudo  kinit  aulfeldt@WAD.ENG.HYTRUST.COM

Password for aulfeldt@WAD.ENG.HYTRUST.COM:
hytrust@ubuntu-ad1:/usr/share/tomcat7/conf$

how does "Client not found in Kerberos database" differ from "Client not found in Kerberos database"? what do these errors really mean?

Best Answer

(this question is a bit old, but my analysis might help others)

You seem to be missing some understanding and therefore not executing the commands correctly. I'm assuming that your KDC is actually an Active Directory KDC. This is not entirely clear from your description.

Firstly, in active directory kerberos (contrary to standard MIT/Heimdal kerberos) a Service Principal Name (SPN - a service running a machine) needs to be connected to a User Principal Name (UPN, a user siting behind a machine). Hence the mapping.

setspn will add the service principal name to a user by adding the ldap attribute to the cn of the user

ktpass will output your key tab and rewrite the UserPrincipalName to username/fully.qualified.domainname@REALM .

By doing a kinit -k -t key.tab principal a lookup will happen in both the key.tab file and active directory UPN on the principal. If it cannot find the principal in the key tab it will give an error like "Key table entry not found while getting initial credentials". If it cannot be found in the directory it will give "Client not found in Kerberos database while getting initial credentials".

Now to your issue at hand. It seems that you are missing the /princ parameter to ktpass. This is required to actually get the principal in the key tab file and get the mapping right. I wonder what a klist -k keytab gives.

so your lines should be something like (including putting the REALM at the right location:

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

ktpass /princ HTTP/ubuntu-ad.wad.eng.hytrust.com@WAD.ENG.HYTRUST.COM /out tomcat.keytab /mapuser aulfeldt /crypto ALL /pass * /ptype KRB5_NT_PRINCIPAL

Extra: if you are using SAMBA 4 with the samba-tool to do this you will need to manually change userPrincipalName to (in this case): HTTP/ubuntu-ad.wad.eng.hytrust.com@WAD.ENG.HYTRUST.COM this is because the key tab generation of samba does not update the UPN and hence you will get an error when doing a lookup.

On a side note: an active directory machine name is COMPUTER$ (mark the $). Your's seems off.