Kerberos
How to create a keytab with ktutil
Find out the details for the given principal
# on the KDC serverkadmin.localgetprinc someUser@SOME.DOMAIN
This should return something like this:
Principal: someUser@SOME.DOMAINExpiration date: [never]Last password change: Wed Jan 08 15:36:12 UTC 2025Password expiration date: Tue Apr 08 15:36:12 UTC 2025Maximum ticket life: 1 day 00:00:00Maximum renewable life: 7 days 00:00:00Last modified: Wed Jan 08 15:36:12 UTC 2025 (root/admin@SOME.DOMAIN)Last successful authentication: [never]Last failed authentication: Tue Jan 21 08:00:44 UTC 2025Failed password attempts: 0Number of keys: 4Key: vno 1, aes256-cts-hmac-sha384-192:specialKey: vno 1, aes128-cts-hmac-sha256-128:specialKey: vno 1, aes256-cts-hmac-sha1-96:specialKey: vno 1, aes128-cts-hmac-sha1-96:specialMKey: vno 1Attributes: REQUIRES_PRE_AUTH DISALLOW_SVRPolicy: [none]
Create the keytab
Now we can generate the keytab file using ktutil
. The following example creates a keytab file with the same name as the principal.
The keytab file will be created in the current working directory and will contain all encryptions for the principal.
# On the target machinektutiladdent -password -p someUser@SOME.DOMAIN -k 1 -e aes256-cts-hmac-sha384-192# enter password manually
addent -password -p someUser@SOME.DOMAIN -k 1 -e aes128-cts-hmac-sha256-128# enter password manually
addent -password -p someUser@SOME.DOMAIN -k 1 -e aes256-cts-hmac-sha1-96# enter password manually
addent -password -p someUser@SOME.DOMAIN -k 1 -e aes128-cts-hmac-sha1-96# enter password manuallywkt someUser.keytabquit
How to create a keytab with kadmin.local
kadmin.local -q 'ktadd -k <KEYTAB_PATH> -norandkey <USER>@<REALM>'
How to use a cache file for authentication
Sometimes you might have to explicitly set the cache file for authentication. This is especially useful when you have multiple Kerberos tickets or when you are using a different cache file than the default one. An example situation would be a test setup where you run multiple tests in parallel with different principals.
KRB5CCNAME=<CACHE_PATH> kinit -kt <KEYTAB_PATH> <USER>@<REALM># alternativelykinit -kt -c <CACHE_PATH> <KEYTAB_PATH> <USER>@<REALM>
References
Hadoop and Kerberos - The Madness Beyond the Gate Kerberos - ELI5