Understanding the Service Principal Name (SPN) as a service's identity in the realm, how to register SPNs from Windows with setspn and from Linux with msktutil and ktpass, and the types of Kerberos delegation along with their risks.

In episode 19 you made Linux servers AD domain citizens: the computer object is registered, the host keytab is generated, and SSSD bridges Kerberos authentication with PAM and NSS. The machine can now prove its identity to the KDC. But what about services? When an application offers HTTP or SSH, the KDC needs to know which service is being requested — that's where the Service Principal Name (SPN) comes in.
Episode 20 dissects the SPN as a service's identity in the realm, how to register it from both Windows and Linux, then dives into the world of Kerberos delegation: the mechanism that lets a service request tickets on behalf of a user. Delegation is an extremely powerful feature and, at the same time, extremely dangerous when configured carelessly.
An SPN is a service's unique identifier within the realm. Its format is always three parts: the service name, the host, and the realm.
| Part | Example | Function |
|---|---|---|
| service | HTTP | The service name being offered (HTTP, SSH, LDAP, cifs, host) |
| host | web01.example.com | The full hostname where the service runs |
| realm | EXAMPLE.COM | The Kerberos realm where the service account is registered |
When a client wants to access the HTTP/web01.example.com service, it requests a service ticket for that SPN from the KDC. The KDC looks up which account owns the SPN, then signs the ticket with that account's key. This is exactly the flow you saw in episode 3: without the correct SPN, the KDC answers KDC_ERR_S_PRINCIPAL_UNKNOWN — "server not found in Kerberos database".
In the Windows world, SPNs are managed with setspn. The SPN is attached to a user or computer account that becomes the service's "identity":
setspn -S HTTP/web01.example.com svc-web
setspn -L svc-web
setspn -Q HTTP/web01.example.comsetspn -S adds while checking for duplicates — this command refuses if the SPN is already owned by another account.setspn -L shows the list of SPNs owned by an account.setspn -Q asks who owns a given SPN; very useful for detecting duplicates.SPNs within a realm must be unique. If two accounts have the same SPN, the KDC doesn't know which key to use when signing the service ticket. The impact: service authentication becomes unstable — sometimes it succeeds, sometimes it fails with KRB_AP_ERR_MODIFIED. Note the following:
setspn -S (not the legacy-era setspn -A) so duplicates are detected immediately at registration.setspn -Q */* and filter results that appear more than once.Tip
A duplicated SPN is almost impossible to diagnose from the client side — its only symptom is KRB_AP_ERR_MODIFIED during connection. Make it a habit to audit setspn -Q */* regularly, not only when a problem appears.
Linux applications also need SPNs, and there are two main paths: using the msktutil tool to manage the machine account and its SPNs from the Linux side, or generating a keytab from AD with ktpass on the Windows side.
msktutil is a utility that lets Linux create and update machine accounts in AD, add SPNs, and write keytabs:
msktutil create --computer-name web01 \
--service HTTP/web01.example.com \
--upn svc-web@EXAMPLE.COM \
--server dc01.example.com \
--keytab /etc/krb5.keytab--service adds an SPN to the machine account.--upn sets the User Principal Name of that account.--keytab specifies the location of the generated keytab file.Once the keytab is available, verify its contents and test passwordless authentication:
klist -kt /etc/krb5.keytab
kinit -k -t /etc/krb5.keytab HTTP/web01.example.comThe classic approach from the Windows side is ktpass, run on a domain controller or a workstation with the RSAT tools:
ktpass -princ HTTP/web01.example.com@EXAMPLE.COM \
-mapuser svc-web \
-crypto AES256-SHA1 \
-ptype KRB5_NT_PRINCIPAL \
-out /tmp/web01.keytab/princ specifies the SPN that becomes the keytab's primary identity./mapuser maps that SPN to the AD account svc-web./crypto AES256-SHA1 ensures only AES encryption is used — avoid RC4 (details in episode 21).klist -kt web01.keytab and kinit -k -t web01.keytab HTTP/web01.example.com.Whether through msktutil or ktpass, the end result is the same: a keytab containing the account key whose SPN matches, ready for the application to accept tickets.
Delegation allows a service to request tickets on behalf of a user to other services. There are three models with different risk levels:
| Type | Configuration | How It Works | Risk |
|---|---|---|---|
| Unconstrained | Trust for delegation to any service | Service receives the user's TGT and can impersonate the user to any service | Very high |
| Constrained | Trust for delegation to specified services | Service can only impersonate the user to registered services | Medium |
| Resource-based | Configured on the resource side | The resource determines which accounts may delegate to it | Controlled |
The oldest model: the front-end receives the user's TGT as part of the flow and stores it in memory. With that TGT, the front-end can request tickets to any service — as long as the TGT is valid. Because the TGT is stored, a single compromised machine immediately grants access to the whole domain. Microsoft recommends avoiding this model except for very isolated special cases.
The second model limits the target: the front-end can only delegate to a specific list of allowed services. Its advantage is support for protocol transition — a user who logs in through non-Kerberos authentication (e.g. NTLM or certificate) can still be transitioned to another Kerberos service. This involves two mechanisms:
The most modern model: configuration is done on the resource (backend) account, not the front-end. The resource declares the list of accounts allowed to delegate to it. Because it's set on the resource, it suits scenarios where the backend owner's team wants to control who may connect to its service. Resource-based delegation also uses S4U2Self and S4U2Proxy, but the configuration direction is reversed.
To enable constrained delegation in AD:
cifs/file01.example.com.Resource-based delegation is configured via PowerShell on the resource account:
Set-ADComputer file01 -PrincipalsAllowedToDelegateToAccount web01$The command above declares: the file01 computer account allows web01 to delegate to it. Control now rests with the resource owner.
To make sure delegation works, run klist in the front-end session and check for the presence of a service ticket for the backend. When the S4U2Proxy flow runs, the front-end will hold a cifs/file01 ticket obtained on behalf of the user. If the ticket doesn't appear even though all configuration is correct, re-check whether the backend SPN is registered on the resource account, and whether the "use any authentication protocol" option is really needed.
Delegation is a gold mine for an attacker who already has access to one service:
krbtgt key, an attacker forges a TGT for any account, including privileged ones. Delegation widens the impact because that forged ticket can be used to impersonate users.Important mitigations you can apply right away:
Warning
Unconstrained delegation hands the user's TGT directly to the service. If you find an account with unconstrained delegation you don't recognize, treat it as a compromise indicator — immediately audit who passed through that service and move it to a constrained or resource-based model.
Episode 20 gave you a complete map of service identity and delegation: the SPN as a service's unique identifier, registration via setspn on Windows and msktutil/ktpass on Linux, a comparison of the three delegation types, and the Golden Ticket and Silver Ticket risks looming over careless configuration.
Key takeaways:
service/host@REALM format and must be unique; use setspn -S and audit setspn -Q */* regularly.msktutil (from Linux) or ktpass (from Windows), and must use AES encryption.In episode 21 you'll shift perspective from "feature" to "weapon": Kerberos Security Best Practices — encryption hardening, KDC security, dissecting Kerberos attacks like Kerberoasting and Pass-the-Ticket, and detection strategies. See you there!