I edited my /etc/krb5.conf file by adding the below to the [libdefaults] section and rebooting the machine
None of those parameters are for krb5.conf – they are parameters for SSSD. Put them in sssd.conf
in the section corresponding to your SSSD "domain".
For the cron solution to work I need to use/renew the expected ticket cache filename shown by klist.
Both klist
and kinit
use the cache path that they receive via the KRB5CCNAME
environment variable. This is not automatically the same for everything that the user runs (indeed the whole point of it being an environment variable is that it could be distinct from the krb5.conf "default" format – the random suffix is added by SSSD deliberately when pam_sss sets the variable for each new login). When it is set by a PAM module for interactive logins, it will not necessarily be set for cronjobs as they might have a different PAM module stack configured.
So if you want to rely on SSSD (remember that it can only keep renewing the ticket for so long), you should make SSSD use a deterministic cache name (using krb5_ccname_template) and then have your cronjobs set KRB5CCNAME
accordingly.
On the other hand, if you are using a keytab, then you should start with setting KRB5CCNAME
for both the 'kinit' cronjob and the actual Kerberos-using tasks to point at some custom location (or unsetting it to use the system default "krb5cc_<uid>").
For example, all our cronjob shellscripts do export KRB5CCNAME=/tmp/krb5cc_${UID}_cron
.
Keep in mind that when you use any method that gets tickets using a keytab, SSSD's cache becomes completely irrelevant; there is almost no point in trying to re-use the same path as SSSD, as kinit -k
will be getting fresh tickets anyway.
However this file has an unexpected name (random numeric characters appended - like "krb5cc_1922807467"),
Those are not "random numeric characters", that's the user's UID (i.e. the %U
part); the stock default cache format is simply FILE:/tmp/krb5cc_<uid>
. The long UID is typical for SSSD's method of mapping Windows SIDs/RIDs to Unix UIDs.
Only the third component added by pam_sss, such as the _7mabEj
in your example, is really randomized.