Concepts / Identity

Identity

Kerberos

Also called KDC, ticket-granting ticket, TGT, service ticket, kinit, keytab, principal, realm, GSSAPI, krb5, Active Directory

A ticket system that lets one password login open many services, each proven with a ticket, never the password again.

The password is used once, then only tickets
The password is used once, then only tickets

The client proves the password to the KDC once and gets a TGT. For each server it trades the TGT for a service ticket, which the server opens with its own key without asking the KDC.

Kerberos is a ticket system: one password login opens many services, each with a ticket, never the password again. kinit proves the password to the KDC and gets a ticket-granting ticket (TGT). For each server the client trades the TGT for a service ticket, sealed with that server's key; the server opens it with its keytab and never contacts the KDC. Tickets carry timestamps, so clocks must be close.

How Kerberos works, step by step

In the Kerberos lab the realm is FERNHILL.LAB. The KDC (10.70.2.10, MIT krb5) knows every key; the drawing archive (.21) holds its own in a keytab; Ada works on the laptop (.30). Kerberos v5 is RFC 4120, on UDP and TCP port 88.

  1. AS_REQ without proof. kinit ada asks the Authentication Service for a ticket to krbtgt/FERNHILL.LAB. Every principal in this realm needs pre-authentication, so the KDC answers NEEDED_PREAUTH.
  2. AS_REQ with the encrypted time. The laptop sends the current time locked with a key made from Ada's password. The KDC opens it with its copy of her key and answers AS_REP: the TGT, locked with the KDC's own key, plus a session key locked for Ada. The password never crosses the network, but both messages are locked with a key made from it, so a weak password can still be guessed offline from a recording.
  3. TGS_REQ. To reach archive/archive.lab, the laptop sends the TGT and an authenticator (Ada's name and the time, locked with the session key) to the Ticket-Granting Service.
  4. TGS_REP. The KDC returns a service ticket locked with the archive's key, and a session key for the two of them.
  5. AP_REQ. The laptop gives the service ticket and a fresh authenticator to the archive. The archive opens the ticket with its keytab, checks the authenticator's time against its own clock (five minutes either way), and knows it's Ada. It never contacts the KDC.

A ticket is good for ten hours here. Logging out (kdestroy) deletes the cache on the laptop and tells nobody.

What it looks like on a Linux machine

After kinit ada and one visit to the archive, the cache holds the TGT and a service ticket:

$ klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: ada@FERNHILL.LAB

Valid starting     Expires            Service principal
11/02/26 14:09:55  11/03/26 00:09:55  krbtgt/FERNHILL.LAB@FERNHILL.LAB
11/02/26 14:09:55  11/03/26 00:09:55  archive/archive.lab@FERNHILL.LAB

MIT's test client and server, sclient and sserver, do the same ticket exchange as any Kerberos service:

$ sclient archive.lab 4444 archive
connected
sendauth succeeded, reply is:
reply len 25, contents:
You are ada@FERNHILL.LAB

The KDC logs each exchange (cipher lists trimmed):

AS_REQ 10.70.2.30: NEEDED_PREAUTH: ada@FERNHILL.LAB for krbtgt/FERNHILL.LAB@FERNHILL.LAB
AS_REQ 10.70.2.30: ISSUE: authtime 1793628595, ada@FERNHILL.LAB for krbtgt/FERNHILL.LAB@FERNHILL.LAB
TGS_REQ 10.70.2.30: ISSUE: authtime 1793628595, ada@FERNHILL.LAB for archive/archive.lab@FERNHILL.LAB

The archive's key, one line per cipher, readable by root only, and the version the ticket was made with:

$ klist -k
Keytab name: FILE:/etc/krb5.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   2 archive/archive.lab@FERNHILL.LAB
   2 archive/archive.lab@FERNHILL.LAB
$ kvno archive/archive.lab
archive/archive.lab@FERNHILL.LAB: kvno = 2

What goes wrong, and how you see it

Clocks apart. An authenticator more than the clock skew (300 s) away from the server's clock is refused: sendauth rejected, Clock skew too great. Run NTP on every machine. kinit itself corrects for a wrong laptop clock from the KDC's replies, so it's a clock that moves after login, or a wrong one on the server, that breaks.

A key changed on one side. cpw -randkey on the KDC alone gives the service a new key version, and the server's keytab still holds the old one: the server answers Key version is not available. ktadd changes both at once; then get fresh tickets.

No pre-authentication. A principal without REQUIRES_PRE_AUTH gets ISSUE with no NEEDED_PREAUTH before it, so anyone can ask for a reply locked with that person's key and guess offline (AS-REP roasting). modprinc +requires_preauth puts the check back.

A copied ticket cache. A cache file is as good as the password until its tickets expire (pass the ticket), and kdestroy can't recall a copy. Keep caches readable by their owner only, and lifetimes short.

No tickets at all. After kdestroy, klist says No credentials cache found, and a Kerberos client can't even say who's asking.

Questions people ask

What port does Kerberos use? 88, UDP and TCP; replies too big for UDP move to TCP. Password changes use 464, and MIT's kadmind 749.

Kerberos vs LDAP? Kerberos proves who you are with tickets; LDAP stores who people are and their groups. Active Directory runs both.

Does the server ask the KDC about each ticket? No. It opens the ticket with its own key from the keytab, so a running service keeps working for hours with the KDC down.

Is Kerberos single sign-on? Yes, inside one realm: one kinit gives tickets for every service. Single sign-on on the web does the same with SAML or OpenID Connect.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab