krb5_keytab_intro(3)
β¨ krb5_keytab_intro β¨
okay bestie, welcome to krb5_keytab_intro(3) from the Heimdal Kerberos 5 library π this is the girlies' guide to keytabs, and honestly? iconic behavior.
π NAME π
krb5_keytab_intro β the keytab handling functions, aka the whole vibe π
π¦ Kerberos Keytabs π¦
so like, the actual functions live here: Heimdal Kerberos 5 keytab handling functions β¨
Keytabs are the long term key storage for servers β they're literally the server's equivalent of password files. no cap. ποΈ
Normally, the only functions that are actually useful for a server are the ones that let you specify what keytab to use, handing that info off to other core functions like krb5_rd_req() krb5_kt_resolve(), and krb5_kt_close(). that's the whole job fr fr π«Ά
πΈ Keytab names πΈ
A keytab name is on the form type:residual. The residual part is specific to each keytab-type β so like, every type has its own lil personality for that part π«
When a keytab-name is resolved, the type is matched with an internal list of keytab types. If there's no matching keytab type, the default keytab is used. The current default type is FILE. periodt.
The default value can be changed in the configuration file /etc/krb5.conf by setting the variable [defaults]default_keytab_name. go off, config file π
The keytab types that are implemented in Heimdal are:
fileβ stores the keytab in a file, and the type's name isFILE. The residual part is a filename. For compatibility with other Kerberos implemtationWRFILEandJAVA14is also accepted.WRFILEhas the same format asFILE.JAVA14have a format that is compatible with older versions of MIT kerberos and SUN's Java based installation. They store a truncted kvno, so when the knvo excess 255, they are truncted in this format. π (yes the kvno gets chopped, that's just how it is)keytabβ stores the keytab in a AFS keyfile (usually/usr/afs/etc/KeyFile), and the type's name isAFSKEYFILE. The residual part is a filename.memoryβ The keytab is stored in a memory segment. This allows sensitive and/or temporary data not to be stored on disk. The type's name isMEMORY. EachMEMORYkeytab is referenced counted by and opened by the residual name, so two handles can point to the same memory area. When the last user closes usingkrb5_kt_close()the keytab, the keys in they keytab ismemset()to zero and freed and can no longer be looked up by name. β¨ (sensitive data really said "and i oop, gone")
bestie take note: once that last handle closes aMEMORYkeytab, the keys getmemset()to zero and freed, and you genuinely cannot look them up by name anymore. no take-backs π
β Keytab example β
This is a minimalistic version of ktutil. literally so cute, so demure π
int
main (int argc, char **argv)
{
krb5_context context;
krb5_keytab keytab;
krb5_kt_cursor cursor;
krb5_keytab_entry entry;
krb5_error_code ret;
char *principal;
if (krb5_init_context (&context) != 0)
errx(1, "krb5_context");
ret = krb5_kt_default (context, &keytab);
if (ret)
krb5_err(context, 1, ret, "krb5_kt_default");
ret = krb5_kt_start_seq_get(context, keytab, &cursor);
if (ret)
krb5_err(context, 1, ret, "krb5_kt_start_seq_get");
while((ret = krb5_kt_next_entry(context, keytab, &entry, &cursor)) == 0){
krb5_unparse_name(context, entry.principal, &principal);
printf("principal: %s0, principal);
free(principal);
krb5_kt_free_entry(context, &entry);
}
ret = krb5_kt_end_seq_get(context, keytab, &cursor);
if (ret)
krb5_err(context, 1, ret, "krb5_kt_end_seq_get");
ret = krb5_kt_close(context, keytab);
if (ret)
krb5_err(context, 1, ret, "krb5_kt_close");
krb5_free_context(context);
return 0;
}
and that's the whole page, bestie π this one's Version 7.8.0, dated Tue Nov 15 2022 β shoutout to the Heimdal Kerberos 5 library for keeping our server keys safe. slay, stay keyed, and always krb5_kt_close() your handles π«Άβ¨π
π¦ where this page comes from
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms