# Kerberos single sign-on

Kerberos is the sign-in system of Windows domains and of many Unix networks. A user logs in once, to the domain, and is then let in to services without typing a password again: their computer shows each service a **ticket**.

CrushMFT uses Kerberos in two directions.

| Direction | Where | Page |
|---|---|---|
| users sign in **to** CrushMFT with a ticket | the [SMB server](Ports-SMB-Server.md) and the [NFS server](Ports-NFS-Server.md) | this page |
| CrushMFT signs in **to** other systems with a ticket | folders and jobs on [SMB shares](VFS-SMB.md), [NFS exports](VFS-NFS.md) and [Hadoop](VFS-Hadoop.md) | this page |

Sign-in to the **web interface** with the domain login is done another way, through an identity provider with SAML or OpenID Connect: see [Plugins](Prefs-Plugins.md).

## The words

| Word | Means |
|---|---|
| realm | the Kerberos name of the domain, in capitals: `EXAMPLE.COM` |
| KDC | the server that issues tickets: in a Windows domain, a domain controller |
| principal | a name in the realm: a person `alex@EXAMPLE.COM`, or a service `cifs/files.example.com@EXAMPLE.COM` |
| keytab | a file that holds the key of a principal. It is to a service what a password is to a person. |

## What CrushMFT needs

Everything is set in the [Kerberos](Prefs-Kerberos.md) section of the Preferences:

- the **realms** and their KDCs, unless they are found by DNS, as in a Windows domain;
- the **credentials**: entries that each hold a principal and its keytab. Folders, jobs and listeners name an entry; they never hold a key themselves.

Keeping the keys in one place has a reason. A VFS item or a job can be edited by people who may not administer the server. If an item could name any keytab file on the disk, such a person could make the server act as any principal whose keytab lies around. An item names an entry, and only an administrator makes entries.

## Users signing in to CrushMFT

### SMB

1. In the domain, make an account for the service and give it the service name `cifs/` followed by the host name clients use: `cifs/files.example.com`. Export its keytab.
2. Add an entry with that keytab in [Kerberos](Prefs-Kerberos.md) and check it there.
3. On the SMB listener, turn on **Kerberos** and choose the entry: see [The SMB server](Ports-SMB-Server.md#who-may-log-in).
4. Say how principals become users: **Strip the realm from the account name** makes `alex@EXAMPLE.COM` the user `alex`.

A Windows user in the domain then opens `\\files.example.com\CrushMFT` without being asked for anything.

### NFS

The same with the service name `nfs/` and the host name clients mount: see [The NFS server](Ports-NFS-Server.md). Kerberos is the only way in to the NFS server.

### Which user

The ticket says who the person is in the realm. CrushMFT needs a user of its own of that name, or a rule that maps the one to the other (**Principal map**). The user's folders, rights and limits are those of the CrushMFT user; the realm only vouches for the name. NFS or SMB must be among the user's allowed protocols.

## CrushMFT signing in elsewhere

An SMB or NFS item, or a Hadoop item, set to Kerberos names an entry of the Kerberos panel. The server gets a ticket for the other system with that entry's keytab and uses it. All users of the item act there as that one principal.

A failed login is not retried at once: after a refusal the server waits before it asks the KDC again, so that a wrong keytab does not lock the account in the domain.

## What usually goes wrong

| Sign | Cause |
|---|---|
| "clock skew too great" | the clocks of the machines differ by more than five minutes. Kerberos refuses. Use a time service everywhere. |
| "server not found in Kerberos database" | the service name does not exist for the host name the client used: `cifs/files` is not `cifs/files.example.com` |
| a ticket is refused although the name is right | the keytab is older than the account's last password change; export it again |
| "encryption type not supported" | the account allows only old encryption types. Enable AES for it in the domain. |
| a keytab made by the domain does not work for a test login | a keytab of a service account is for **accepting** tickets; some cannot be used to **ask** for one. Make an account for the purpose. |
| it works by one host name and not by another | every name clients use needs its own service name on the account |

The **Test** of an entry in the Kerberos panel asks the KDC and says what it answered. The log kinds for Kerberos in [Logging](Prefs-Logging.md) show each step.

## In FIPS mode

NTLM, the password login of SMB, is not available in [FIPS mode](FIPS-Mode.md). Kerberos with AES is, and becomes the only login for SMB.
