Kerberos Auth Method
The kerberos
auth method provides an automated mechanism to retrieve
a Vault token for Kerberos entities.
Kerberos is a network authentication protocol invented by MIT in the 1980s. Its name is inspired by Cerberus, the three-headed hound of Hades from Greek mythology. The three heads refer to Kerberos' three entities - an authentication server, a ticket granting server, and a principals database. Kerberos underlies authentication in Active Directory, and its purpose is to distribute a network's authentication workload.
Vault's Kerberos auth method was originally written by the folks at Winton, to whom we owe a special thanks for both originally building the plugin, and for collaborating to bring it into HashiCorp's maintenance.
Prerequisites
Kerberos is a very hands-on auth method. Other auth methods like LDAP and Azure only require a cursory amount of knowledge for configuration and use. Kerberos, on the other hand, is best used by people already familiar with it. We recommend that you use simpler authentication methods if your use case is achievable through them. If not, we recommend that before approaching Kerberos, you become familiar with its fundamentals.
- MicroNugget: How Kerberos Works in Windows Active Directory
- MIT's Kerberos Documentation
- Kerberos: The Definitive Guide
Regardless of how you gain your knowledge, before using this auth method, ensure you are comfortable with Kerberos' high-level architecture, and ensure you've gone through the exercise of:
- Creating a valid
krb5.conf
file - Creating a valid
keytab
file - Authenticating to your domain server with your
keytab
file usingkinit
With that knowledge in hand, and with an environment that's already tested and confirmed working, you will be ready to use Kerberos with Vault.
Configuration
- Enable Kerberos authentication in Vault:
- Create a
keytab
for the Kerberos plugin:
The KVNO (-k 1
) should match the KVNO of the service account. An error will show in the Vault logs if this is incorrect.
Different encryption types can also be added to the keytab
, for example -e rc4-hmac
with additional addent
commands.
Then base64 encode it:
- Configure the Kerberos auth method with the
keytab
and entry name that will be used to verify inbound login requests:
- Configure the Kerberos auth method to communicate with
LDAP using the service account configured above. This is
a sample LDAP configuration. Yours will vary. Ensure you've
first tested your configuration from the Vault server using
a tool like
ldapsearch
.
The LDAP above relies upon the same code as the LDAP auth method. See its documentation for further discussion of available parameters.
- Configure the Vault policies that should be granted to those who successfully authenticate based on their LDAP group membership. Since this is identical to the LDAP auth method, see Group Membership Resolution and LDAP Group -> Policy Mapping for further discussion.
The above group grants the "engineers" policy to those who authenticate via Kerberos and are found to be members of the "engineering-team" LDAP group.
Authentication
From a client machine with a valid krb5.conf
and keytab
, perform a command
like the following:
krb5conf_path
is the path to a validkrb5.conf
file describing how to communicate with the Kerberos environment.keytab_path
is the path to thekeytab
in which the entry lives for the entity authenticating to Vault. Keytab files should be protected from other users on a shared server using appropriate file permissions.username
is the username for the entry within thekeytab
to use for logging into Kerberos. This username must match a service account in LDAP.service
is the service principal name to use in obtaining a service ticket for gaining a SPNEGO token. This service must exist in LDAP.realm
is the name of the Kerberos realm. This realm must match the UPNDomain configured on the LDAP connection. This check is case-sensitive.disable_fast_negotiation
is for disabling the Kerberos auth method's default of using FAST negotiation. FAST is a pre-authentication framework for Kerberos. It includes a mechanism for tunneling pre-authentication exchanges using armoured KDC messages. FAST provides increased resistance to passive password guessing attacks. Some common Kerberos implementations do not support FAST negotiation.
Troubleshooting
Identify the Malfunctioning Piece
Once the malfunctioning piece of the journey is identified, you can focus your debugging efforts in the most useful direction.
- Use
ldapsearch
while logged into your machine hosting Vault to ensure your LDAP configuration is functional. - Authenticate to your domain server using
kinit
, yourkeytab
, and yourkrb5.conf
. Do this with both Vault'skeytab
, and any clientkeytab
being used for logging in. This ensures your Kerberos network is working. - While logged into your client machine, verify you can reach Vault
through the following command:
$ curl $VAULT_ADDR/v1/sys/health
.
Build Clear Steps to Reproduce the Problem
If possible, make it easy for someone else to reproduce the problem who is outside of your company. For instance, if you expect that you should be able to login using a command like:
Then make sure you're ready to share the error output of that command, the
contents of the krb5.conf
file, and the entries listed
in the keytab
file.
After you've stripped the issue down to its simplest form, if you still encounter difficulty resolving it, it will be much easier to gain assistance by posting your reproduction to the Vault Forum or by providing it to HashiCorp Support (if applicable.)
Additional Troubleshooting Resources
The Vault Kerberos library has a working integration test environment that can be referenced as an example of a full Kerberos and LDAP environment. It runs through Docker and can be started through either one of the following commands:
These commands run variations of a script that spins up a full environment, adds users, and executes a login from a client.
API
The Kerberos auth method has a full HTTP API. Please see the Kerberos auth method API for more details.