Windows and Linux Integration Series 3: Kerberos with Active Directory (Tickets, SPNs, Keytabs and Clock Skew)

Windows and Linux Integration Series, part 3. Previous: part 2, DNS, Time Sync, Hostnames and Firewall Ports Before an Active Directory Join. Start of the series: part 1, Overview and Choosing an Approach. This part explains Kerberos as Active Directory uses it, and how that differs from the standalone MIT KDC in the MIT Kerberos series. Next up: preparing Active Directory for Unix clients (part 4).

Every method of joining a Unix host to Active Directory in this series (realmd with SSSD, adcli, Winbind) is, underneath, Kerberos. Logins are checked with a Kerberos AS exchange, the host proves who it is with a keytab, file servers accept users with service tickets, and kerberized NFS and SSH single sign-on are just more service tickets. When something fails later, the error is usually a Kerberos error, and it reads much more easily once you know which part of the exchange it came from. This post covers tickets, principals and SPNs, keytabs and machine accounts, encryption types, and the five-minute clock skew, with commands you can run against AD from an AlmaLinux host before it is joined.

Applies to: AlmaLinux, RHEL, Rocky Linux and Oracle Linux 9 and 10 (MIT Kerberos 1.21 client tools), with domain controllers on Windows Server 2016 through 2025. Solaris 10 and 11.4 use the same concepts with their own kinit/klist and /etc/krb5/krb5.conf; the Solaris join comes later in the series. The lab is the one from part 2: domain corp.example.com, realm CORP.EXAMPLE.COM, DCs dc1 (192.168.10.10) and dc2 (192.168.10.11), host rhel1.corp.example.com (192.168.10.20).

Prerequisites

  • DNS, time and host name fixed as in part 2: rhel1 resolves the domain’s SRV records through the DCs, and chronyc tracking shows it synchronized.
  • An ordinary AD test user (here jdoe) and its password. No admin rights are needed for anything in this post until the keytab section.
  • Root or sudo on the Linux host to install packages and edit /etc/krb5.conf.
  • Optionally a Windows admin workstation with RSAT, or PowerShell on a DC, to look at SPNs and encryption types.

Kerberos in AD, in one picture

Kerberos termIn Active Directory
RealmThe DNS domain in upper case: CORP.EXAMPLE.COM. There is one realm per domain.
KDCEvery writable domain controller is a KDC (the Kerberos Key Distribution Center service, kdc). There is no separate KDC to install or replicate.
Principal databaseThe directory itself. User principals are user objects; their keys are derived from the AD password.
User principaljdoe@CORP.EXAMPLE.COM, from the sAMAccountName; the UPN (userPrincipalName) is also accepted.
Host / service principalA computer account (RHEL1$) whose servicePrincipalName attribute lists names such as host/rhel1.corp.example.com.
kadminNot used. Accounts and SPNs are managed with ADUC, PowerShell, setspn, or from Linux with adcli, realm and net ads.
Locating KDCsDNS SRV records _kerberos._tcp.corp.example.com and _kerberos._udp, created by AD.

Compared with the standalone MIT KDC: there you create principals with kadmin, extract keys with ktadd, and replicate with kprop (primary and replica KDCs). In AD the same jobs are spread across the directory, its replication, and the computer account that represents each Linux host.

Step 1: Install the client tools and a minimal krb5.conf

[root@rhel1 ~]# dnf install -y krb5-workstation
[root@rhel1 ~]# rpm -q krb5-workstation krb5-libs

Keep /etc/krb5.conf short and let DNS find the KDCs. The packaged file already includes /etc/krb5.conf.d/, so put the AD settings in a drop-in. realmd will write its own settings at join time; this file is only for testing now:

# /etc/krb5.conf.d/corp.conf
[libdefaults]
    default_realm = CORP.EXAMPLE.COM
    dns_lookup_kdc = true
    dns_lookup_realm = false
    rdns = false
    dns_canonicalize_hostname = false

[domain_realm]
    .corp.example.com = CORP.EXAMPLE.COM
    corp.example.com = CORP.EXAMPLE.COM

rdns = false stops the library from reverse-resolving the server address to build the service principal name, which is the most common reason Linux asks AD for a ticket to a name it does not have. dns_canonicalize_hostname = false means the name you type is the name used for the SPN, so use FQDNs.

[root@rhel1 ~]# dig +short -t SRV _kerberos._tcp.corp.example.com
0 100 88 dc1.corp.example.com.
0 100 88 dc2.corp.example.com.

Step 2: Get a ticket-granting ticket (AS exchange)

[jdoe@rhel1 ~]$ kinit jdoe@CORP.EXAMPLE.COM
Password for jdoe@CORP.EXAMPLE.COM:
[jdoe@rhel1 ~]$ klist
Ticket cache: KCM:1000
Default principal: jdoe@CORP.EXAMPLE.COM

Valid starting       Expires              Service principal
12/04/2026 10:15:02  12/04/2026 20:15:02  krbtgt/CORP.EXAMPLE.COM@CORP.EXAMPLE.COM
        renew until 12/11/2026 10:15:02

Three things in that output come from AD, not from Linux. The realm must be typed in upper case. The ten-hour ticket lifetime and seven-day renewal limit are the defaults of the domain’s Kerberos policy (in the Default Domain Policy GPO, under Account Policies, Kerberos Policy), so do not expect ticket_lifetime in krb5.conf to give you more than AD allows. And the cache type KCM: is the RHEL default (the sssd-kcm service), which keeps tickets per user across sessions.

AD requires pre-authentication by default: the client proves it knows the password by encrypting a timestamp. That timestamp is why clocks matter.

Step 3: Ask for a service ticket (TGS exchange) and see SPNs at work

With a TGT you can ask for a ticket to any service whose SPN is registered. Every DC has ldap/ and host/ SPNs, so this works on an unjoined host:

[jdoe@rhel1 ~]$ kvno ldap/dc1.corp.example.com
ldap/dc1.corp.example.com@CORP.EXAMPLE.COM: kvno = 12
[jdoe@rhel1 ~]$ klist -e
...
12/04/2026 10:16:40  12/04/2026 20:15:02  ldap/dc1.corp.example.com@CORP.EXAMPLE.COM
        Etype (skey, tkt): aes256-cts-hmac-sha1-96, aes256-cts-hmac-sha1-96

The kvno is the key version number of the DC’s computer account; it goes up each time that account’s password changes. The Etype line shows the encryption type the ticket and session key use. If you ask for a name nobody registered, AD says so:

[jdoe@rhel1 ~]$ kvno host/rhel1.corp.example.com
kvno: Server not found in Kerberos database while getting credentials for host/rhel1.corp.example.com@CORP.EXAMPLE.COM

That is the expected answer for a host that is not joined yet. After the join (parts 7 to 9) the same command succeeds, because the join creates the RHEL1$ computer account with host/rhel1.corp.example.com and host/RHEL1 SPNs. On Windows you can list them:

PS C:\> setspn -L RHEL1
Registered ServicePrincipalNames for CN=RHEL1,OU=Linux Servers,DC=corp,DC=example,DC=com:
        RestrictedKrbHost/rhel1.corp.example.com
        RestrictedKrbHost/RHEL1
        host/rhel1.corp.example.com
        host/RHEL1

SPNs must be unique in the forest. setspn -Q host/rhel1.corp.example.com searches for an existing owner, and setspn -X reports duplicates. A duplicate SPN produces confusing “decrypt integrity check failed” errors, because AD encrypts the ticket with one account’s key while the host holds the other’s.

Keytabs and the machine account

With an MIT KDC you create a host principal and export its key into /etc/krb5.keytab (see Create and Manage Kerberos Keytabs). In AD, the computer account has a password, and the keytab holds keys derived from it. The join tools (realmd, adcli, net ads join) set a random machine password and write the keytab in the same step. After a join, inspect it like this:

[root@rhel1 ~]# klist -k -e /etc/krb5.keytab
Keytab name: FILE:/etc/krb5.keytab
KVNO Principal
---- ------------------------------------------------------------
   2 RHEL1$@CORP.EXAMPLE.COM (aes256-cts-hmac-sha1-96)
   2 RHEL1$@CORP.EXAMPLE.COM (aes128-cts-hmac-sha1-96)
   2 host/RHEL1@CORP.EXAMPLE.COM (aes256-cts-hmac-sha1-96)
   2 host/rhel1.corp.example.com@CORP.EXAMPLE.COM (aes256-cts-hmac-sha1-96)
...
[root@rhel1 ~]# kinit -k 'RHEL1$@CORP.EXAMPLE.COM' && klist
[root@rhel1 ~]# kdestroy

kinit -k proves the keytab matches what AD has. Two AD-specific rules follow from the machine password:

  • The password rotates. SSSD changes it on a schedule (ad_maximum_machine_account_password_age, 30 days by default) and updates the keytab; the kvno goes up. Do not copy a host keytab to another machine or restore an old one from backup; the old kvno no longer works.
  • One keytab owner per account. If two tools (SSSD and Samba, for example) both rotate the same machine password, one of them ends up with a stale keytab. Part 9 covers how Winbind setups avoid that.

Service keytabs for NFS or HTTP use more SPNs on the same computer account (nfs/rhel1.corp.example.com, HTTP/...), added with adcli update --service-name or at join time. Secure NFS with Active Directory Kerberos shows that for nfs/.

Encryption types

Current AD and RHEL agree on AES (aes256-cts-hmac-sha1-96 and aes128-cts-hmac-sha1-96). RC4 (arcfour-hmac) and DES are disabled by default in the RHEL 9 and 10 system-wide crypto policy, and DES has long been off in AD. What AD uses for a given account depends on its msDS-SupportedEncryptionTypes attribute and on domain policy:

PS C:\> Get-ADComputer RHEL1 -Properties msDS-SupportedEncryptionTypes |
          Select-Object Name, msDS-SupportedEncryptionTypes
Name  msDS-SupportedEncryptionTypes
----  -----------------------------
RHEL1                            24

24 is the bit mask for AES128 (8) plus AES256 (16). Realmd and adcli set this on accounts they create. Very old service accounts that were created before AES keys existed may only have RC4 keys until their password is changed once; resetting the password generates AES keys for them. Do not re-enable RC4 on the Linux side to work around that.

[root@rhel1 ~]# update-crypto-policies --show
DEFAULT

The five-minute clock skew

AD rejects a request whose timestamp is more than five minutes from the DC’s clock (the “Maximum tolerance for computer clock synchronization” Kerberos policy, 5 minutes by default). Pre-authentication timestamps, authenticators and ticket times are all checked against it. The cure is the chrony setup from part 2, pointed at the DCs or at the same source the PDC emulator uses. Check it from Linux:

[root@rhel1 ~]# chronyc tracking | grep -E 'Reference|System time'
Reference ID    : C0A80A0A (dc1.corp.example.com)
System time     : 0.000183 seconds fast of NTP time

The error when it is wrong is unambiguous:

kinit: Clock skew too great while getting initial credentials

Seeing the whole exchange: KRB5_TRACE

MIT Kerberos prints every step if you set KRB5_TRACE. This is the first thing to run when a join or login fails:

[jdoe@rhel1 ~]$ KRB5_TRACE=/dev/stderr kinit jdoe@CORP.EXAMPLE.COM
[2245] 1765199702.1 : Getting initial credentials for jdoe@CORP.EXAMPLE.COM
[2245] 1765199702.2 : Sending unauthenticated request
[2245] 1765199702.3 : Sending request (190 bytes) to CORP.EXAMPLE.COM
[2245] 1765199702.4 : Resolving service _kerberos._udp.corp.example.com
[2245] 1765199702.5 : Initiating TCP connection to stream 192.168.10.10:88
[2245] 1765199702.6 : Received error from KDC: -1765328359/Additional pre-authentication required
...
[2245] 1765199704.9 : Received answer (1580 bytes) from stream 192.168.10.10:88

The first “pre-authentication required” reply is normal: the client sends an empty request, the DC asks for pre-authentication, and the client tries again with the encrypted timestamp. The trace also shows which DC answered and whether UDP or TCP was used; AD tickets that carry group membership (the PAC) are often too large for UDP, so the library switches to TCP.

Verification checklist

  • dig -t SRV _kerberos._tcp.corp.example.com lists your DCs.
  • kinit jdoe@CORP.EXAMPLE.COM and klist show a krbtgt/CORP.EXAMPLE.COM ticket with AES.
  • kvno ldap/dc1.corp.example.com returns a kvno.
  • chronyc tracking is within a fraction of a second.
  • After a later join: klist -k lists RHEL1$ and host/ keys, and kinit -k works.

Troubleshooting

ErrorWhere it comes from and what to check
Cannot find KDC for realm "corp.example.com"Realm typed in lower case, or no SRV records via your resolver. Use upper case; check /etc/resolv.conf points at the DCs.
Client not found in Kerberos databaseUser name or realm is wrong, or the account is in another domain of the forest.
Preauthentication failedWrong password (or an old one cached by a script). Repeated failures can lock the AD account.
Clock skew too greatMore than five minutes apart. Fix chrony; do not change the AD policy.
Server not found in Kerberos databaseNo account has that SPN. Check the exact name with setspn -Q; check rdns and that you used the FQDN.
KDC has no support for encryption typeThe account has no AES keys or AES is not allowed for it. Check msDS-SupportedEncryptionTypes; reset old service-account passwords.
Decrypt integrity check failedDuplicate SPN, or a keytab with an old kvno. setspn -X; compare klist -k kvno with kvno output.
KDC reply did not match expectationsRealm case mismatch between request and krb5.conf domain_realm mapping.

Where this fits in the series

Windows and Linux Integration Series, part 3. Previous: part 2, DNS, Time Sync, Hostnames and Firewall Ports. Start: part 1, Overview and Choosing an Approach. Next up: part 4, preparing Active Directory for Unix clients (a computer OU, a least-privilege join account and a domain inventory), then part 5 on POSIX attributes (RFC2307). For the standalone MIT side of the same ideas, see Set Up an MIT Kerberos KDC, Kerberos Keytabs, Primary and Replica KDCs and Configure a Kerberos Client on AlmaLinux 10.

References: Red Hat Enterprise Linux 9 Integrating RHEL systems directly with Windows Active Directory; MIT Kerberos documentation for krb5.conf (rdns, dns_canonicalize_hostname), kvno, klist and KRB5_TRACE; Microsoft Learn: Kerberos Policy settings (maximum lifetime for user ticket, maximum tolerance for computer clock synchronization), setspn, and msDS-SupportedEncryptionTypes; sssd-ad(5) for ad_maximum_machine_account_password_age.

Leave a Reply

Your email address will not be published. Required fields are marked *