# Kerberos service principals and keytabs with FreeIPA in practice

Source: https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice
Language: en
Published: 2026-10-14
Updated: 2026-11-21

Create, inspect and validate service principals and keytabs on Fedora 44 with real GSSAPI authentication.

## Overview

Part 7 of the Identity series covers Kerberos service principals and keytabs with FreeIPA on Fedora 44. The article does not only show how to create a keytab, but also how to verify that a service can actually accept Kerberos authentication with it.

A keytab is a secret key container for a principal. It does not belong in screenshots, tickets or Git repositories. The article therefore shows metadata, principal names, ticket lists and test results, but no key material.

[![FreeIPA Web UI in the Fedora 44 keytab lab](https://forgeone.solutions/media/01-freeipa-dashboard-keytab-fedora.png)](https://forgeone.solutions/media/01-freeipa-dashboard-keytab-fedora.png)

FreeIPA Web UI in the Fedora 44 keytab lab. Screenshot from the isolated FreeIPA C5 keytab lab on Fedora 44.

## Lab Setup

```bash
Server:        ipa01.example.test
Client:        client01.example.test
Service host:  app01.example.test
Service:       HTTP/app01.example.test
Domain:        example.test
Realm:         EXAMPLE.TEST
Distribution:  Fedora Linux 44
SELinux:       Enforcing
```

## Create the Service Principal

The service principal describes the service identity. The lab uses \`HTTP/app01.example.test@EXAMPLE.TEST\`. The name follows the common service/FQDN@REALM pattern.

```bash
ipa host-add app01.example.test --force
ipa service-add HTTP/app01.example.test --force
ipa service-show HTTP/app01.example.test --all
```

[![FreeIPA service principal HTTP/app01.example.test with Kerberos key present](https://forgeone.solutions/media/03-freeipa-service-http-app01-keytab-fedora.png)](https://forgeone.solutions/media/03-freeipa-service-http-app01-keytab-fedora.png)

FreeIPA service principal HTTP/app01.example.test with Kerberos key present. Screenshot from the isolated FreeIPA C5 keytab lab on Fedora 44.

[![FreeIPA host app01.example.test as managed-by target of the service principal](https://forgeone.solutions/media/04-freeipa-host-app01-keytab-fedora.png)](https://forgeone.solutions/media/04-freeipa-host-app01-keytab-fedora.png)

FreeIPA host app01.example.test as managed-by target of the service principal. Screenshot from the isolated FreeIPA C5 keytab lab on Fedora 44.

## Generate and Inspect the Keytab

\`ipa-getkeytab\` writes keys for the service principal into a local keytab file. Immediately afterwards, \`klist -k -e\` verifies which principal and encryption-type entries are present. The key value itself is not printed.

```bash
ipa-getkeytab \
  -s ipa01.example.test \
  -p HTTP/app01.example.test \
  -k /tmp/http-app01.keytab

klist -k -e /tmp/http-app01.keytab
```

```text
Keytab successfully retrieved and stored in: /tmp/http-app01.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   1 HTTP/app01.example.test@EXAMPLE.TEST (aes256-cts-hmac-sha384-192)
   1 HTTP/app01.example.test@EXAMPLE.TEST (aes128-cts-hmac-sha256-128)
   1 HTTP/app01.example.test@EXAMPLE.TEST (aes256-cts-hmac-sha1-96)
   1 HTTP/app01.example.test@EXAMPLE.TEST (aes128-cts-hmac-sha1-96)
```

## Protect the Keytab on the Service System

In the lab, the keytab is installed as root-owned with mode 0600. The later positive GSSAPI test therefore had to run the acceptor process with root privileges. That is intentional: a readable keytab is effectively a service password.

```bash
install -o root -g root -m 0600 \
  /tmp/http-app01.keytab \
  /etc/krb5.keytabs-http-app01.keytab
```

## Service TGT with kinit -k

The first technical proof is \`kinit -k\`: the service can obtain a ticket from the keytab without interactive password entry.

```bash
kinit -k \
  -t /etc/krb5.keytabs-http-app01.keytab \
  HTTP/app01.example.test

klist -e
```

```text
Ticket cache: KCM:0
Default principal: HTTP/app01.example.test@EXAMPLE.TEST

Valid starting       Expires              Service principal
10/08/2026 21:10:20  10/09/2026 21:04:06  krbtgt/EXAMPLE.TEST@EXAMPLE.TEST
```

## Real Service Authentication

A successful \`kinit -k\` proves that the keytab is usable. For stronger acceptance, the lab also performed a GSSAPI client/server test: user \`krbuser\` obtains a service ticket for \`HTTP/app01.example.test\`, and the service accepts the context with the keytab.

[![FreeIPA user krbuser for the GSSAPI client test](https://forgeone.solutions/media/05-freeipa-user-krbuser-keytab-fedora.png)](https://forgeone.solutions/media/05-freeipa-user-krbuser-keytab-fedora.png)

FreeIPA user krbuser for the GSSAPI client test. Screenshot from the isolated FreeIPA C5 keytab lab on Fedora 44.

```text
kvno HTTP/app01.example.test
HTTP/app01.example.test@EXAMPLE.TEST: kvno = 1

client_complete= True
server_initiator= krbuser@EXAMPLE.TEST
```

## Negative Test

An empty or wrong keytab must not obtain credentials. This negative test prevents an existing ticket cache from being mistaken for success.

```bash
KRB5_KTNAME=/tmp/empty-http-app01.keytab \
  kinit -k HTTP/app01.example.test

kinit: Pre-authentication failed: Invalid argument while getting initial credentials
empty_keytab_rc=1
```

## Result Check

| Area | Check | Result |
| --- | --- | --- |
| Platform | Server and client on Fedora Linux 44 | PASS |
| FreeIPA | host app01.example.test exists | PASS |
| FreeIPA | service HTTP/app01.example.test exists | PASS |
| Keytab | ipa-getkeytab creates keytab | PASS |
| Keytab | klist -k -e shows principal and enctypes | PASS |
| Permission | keytab root-owned 0600 | PASS |
| Kerberos | kinit -k with service principal | PASS |
| Kerberos | kvno obtains service ticket | PASS |
| GSSAPI | service accepts client context | PASS |
| Negative test | empty keytab fails | PASS |

## Practice Notes

- Treat keytabs like passwords: restrictive permissions, controlled rollout and no storage in repositories.
- When a keytab is regenerated, the key version context typically changes. Old keytabs must be replaced deliberately.
- For production services, also document ticket lifetime, clock skew, DNS/FQDN consistency, service names and rotation.

## Do Not Skip This

- Treat keytabs like passwords and never store them in tickets or repositories.
- In addition to kinit -k, validate real service authentication.
- Document keytab rotation and KVNO changes.
- Check file permissions and service user as part of acceptance.

## Hero image

[![FreeIPA service principal HTTP/app01.example.test with Kerberos key present](https://forgeone.solutions/media/03-freeipa-service-http-app01-keytab-fedora.png)](https://forgeone.solutions/media/03-freeipa-service-http-app01-keytab-fedora.png)

## Author

Mathias Rumbold

## Category

- [Identity & Access](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?category=identity-access)

## Tags

- [FreeIPA](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=freeipa)
- [Identity Management](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=identity-management)
- [Linux](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=linux)
- [Kerberos](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=kerberos)
- [Security](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=security)
- [Red Hat IdM](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=red-hat-idm)
- [fedora](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice?tags=fedora)

## Need reliable Kerberos and Linux SSO operations?

ForgeOne supports FreeIPA, Kerberos, service principals, keytabs, SSSD, HBAC, sudo rules and documented identity acceptance.

[Discuss an identity project](https://forgeone.solutions/en/contact)

## Identity Management mit FreeIPA und Keycloak

Die Beiträge bauen praktisch aufeinander auf: Fedora-44-basierter FreeIPA-Server, Linux-Clients, Identity-Lifecycle, Passwort-Richtlinien, HBAC, sudo-Regeln, Kerberos-Keytabs, Updates, Backup, Recovery und Hochverfügbarkeit.

1. [Installing FreeIPA: From the First Server to an Enrolled Linux Client](https://forgeone.solutions/en/tech/install-freeipa)
2. [Connect Linux Clients to FreeIPA: SSSD, Kerberos and Centralized Users](https://forgeone.solutions/en/tech/connect-linux-clients-freeipa-sssd-kerberos-centralized-users)
3. [Managing FreeIPA Users and Groups: Identity Lifecycle in Practice](https://forgeone.solutions/en/tech/managing-freeipa-users-groups-identity-lifecycle-practice)
4. [FreeIPA Password Policies in Practice: Expiration, Lockout and Authentication Behavior](https://forgeone.solutions/en/tech/freeipa-password-policies-expiration-lockout-practice)
5. [FreeIPA HBAC in Practice: Control SSH Access by User, Group and Host](https://forgeone.solutions/en/tech/freeipa-hbac-ssh-access-user-group-host-practice)
6. [FreeIPA sudo rules in practice: delegate commands without root passwords](https://forgeone.solutions/en/tech/freeipa-sudo-rules-command-delegation-practice)
7. [Kerberos service principals and keytabs with FreeIPA in practice (current part)](https://forgeone.solutions/en/tech/freeipa-kerberos-service-principals-keytabs-practice)
8. [Updating FreeIPA: package updates, replicas and client compatibility checks](https://forgeone.solutions/en/tech/freeipa-update-package-updates-replicas-client-compatibility)
9. [FreeIPA backup in practice: ipa-backup, certificates, LDAP and recovery windows](https://forgeone.solutions/en/tech/freeipa-backup-ipa-backup-certificates-ldap-recovery)
10. [FreeIPA disaster recovery: restore, replica rebuilds and emergency access testing](https://forgeone.solutions/en/tech/freeipa-disaster-recovery-restore-replica-rebuild-emergency-access)
11. [Running FreeIPA highly available: replication, CA roles, DNS and maintenance workflows](https://forgeone.solutions/en/tech/freeipa-high-availability-replication-ca-dns-maintenance)
