msktutil
fetches and manages kerberos keytabs in an Active Directory environment
- Provided by: msktutil (Version: 0.5.1-1)
- Report a bug
fetches and manages kerberos keytabs in an Active Directory environment
msktutil [command 1] [command 2] [command 3] ...
msktutil is a Unix/Linux keytab client for Microsoft Active Directory environments. This program is capable of creating accounts in Active Directory, adding service principals to those accounts, and creating local keytab files so that kerberizied services can utilize Active directory as a Kerberos realm. msktutil will create and manage machine accounts by default. The --use-service-account option lets msktutil operate on service accounts. msktutil requires that the Kerberos client libraries are properly installed and configured to use Active Directory as a realm.
Whenever a principal is added or a keytab is updated, the secret password for the corresponding account is changed. By default, the password is not stored, so it needs to be reset each time msktutil is executed. All entries in the keytab will be automatically updated whenever the password is reset. The previous entries will be left in the keytab, so sessions using the older key versions will not break. This behavior is similar to the way Windows hosts handle machine password changes.
There are two common methods of using this program. The first is to "kinit" with Administrator-like credentials which have permission to create computer objects in your Active Directory server. If you invoke the program with such credentials, you can create a new computer account or service account from scratch.
The second is to pre-create the accounts with such credentials, and then invoke msktutil on a machine without any special permissions. When the computer account or service account exists already, msktutil will attempt to authenticate as that account using either the existing keytab, or if that fails, a default password. When that default password is not specified with the option --old-account-password, msktutil will use the default machine password. It will then change the password and update the keytab appropriately. This is usually the more convenient option when joining many computers to the domain.
To pre-create a computer account, you may use the Active Directory Users and Computers GUI, select "new computer" from the right click menu, and type the short DNS name, then right click on the newly created object and select "Reset account" to set the password to the default value. Another alternative is to invoke msktutil with the --precreate argument. Both methods accomplish the same thing.
To pre-create a service account, you may use the Active Directory Users and Computers GUI, select "new user" from the right click menu, fill in all required data, set the password to a specific value and use setspn.exe to set the desired servicePrincipalName(s). You may also select "must change password at next logon".
Be aware that Windows machines will, by default, automatically change their account password every 30 days, and thus many domains have a 90-day password expiry window, after which your keytab will stop working. There are two ways to deal with this:
a) (Preferred): Make sure you're running a daily cron job to run msktutil --auto-update, which will change the password automatically 30 days after it was last changed and update the keytab.
b) (Not preferred): disable password expiry for the account via the --dont-expire-password option (or otherwise setting DONT_EXPIRE_PASSWORD flag in userAccountControl in AD).
This section only applies to msktutil --use-service-account.
While machine account passwords may be changed at any time, service accounts are user accounts and your Active Directory domain may have special password policies for those user accounts. E.g., "minimum password age" is typically set to 1 day, which means that you will have to wait for that time to pass until you may invoke msktutil --update --use-service-account.
Unlike other kerberos implementations, Active Directory has only a single key for all of the principals associated with an account. So, if you create a HTTP/hostname service principal, it will share the same key as the host/hostname principal. If you want to isolate (security-wise) different service principals, you may want to create a dedicated service account for them (with --use-service-account) and a separate keytab file (with --keytab).
Also note: kinit -k 'host/computername' *will not work*, by default, even when that is a valid service principal existing in your keytab. Active Directory does not allow you to authenticate as a service principal, so do not use that as a test of whether the service principal is working. If you actually want to authenticate as the computer account user, kinit -k 'computername$' instead.
If you really need to be able to authenticate as 'host/computername', you can also use the --upn argument to set the userPrincipalName attribute (generally requires administrator credentials, not computer account credentials). Both 'computername$' and the value of userPrincipalName are treated as valid account names to kinit as.
msktutil will use kerberized LDAP operations to talk to domain controllers. To obtain a LDAP service ticket, the DNS service will be used to construct the domain controllers LDAP principal name. If DNS is mis-configured, this construction may fail. To work around this issue, you may specify the fully qualified DNS name of your domain controller with the --server option and additionally use the --no-reverse-lookups option.
Samba (www.samba.org) provides the net command that can be used to manage kerberos keytabs as well. Using msktutil and commands like "net ads join" or "net ads keytab" together can lead to trouble. With the --set-samba-secret option, msktutil can be used as a replacement for net.
Active Directory includes authorization data (e.g. information about group memberships) in Kerberos tickets. This information is called PAC and may lead to very large ticket sizes. Especially HTTP services are known to produce failures if that size exceeds the HTTP header size. If your service does not make use of that PAC information (which is true for most Unix/Linux-services) you may just disable it with the --no-pac option.
If not specified, the default value is read from AD (and the default there, unless modified by an admin, is CN=Computers for machine accounts and CN=Users for service accounts).
That is: if the realm is EXAMPLE.COM, and the hostname is FOO.EXAMPLE.COM, the default computer name is FOO. If the hostname is FOO.BAR.EXAMPLE.COM, the default computer name is FOO-BAR.
You may OR together the following values:
0x1=des-cbc-crc
0x2=des-cbc-md5
0x4=rc4-hmac-md5
0x8=aes128-cts-hmac-sha1
0x10=aes256-cts-hmac-sha1
This value is used to determine which encryption types AD will offer to use, and which encryption types to put in the keytab.
If the value is set to 0x3 (that is: only the two DES types), it also attempts to set the DES-only flag in userAccountControl.
Note: Windows 2008R2 refuses to use DES by default; you thus cannot use DES-only keys unless you have enabled DES encryption for your domain first. Recent versions of MIT kerberos clients similarly refuse to use DES by default.
Default: sets the value to 0x1C: that is, use anything but DES.
For unprivileged users the most common invocations are:
msktutil --update --service host --service HTTP
This will update a computer account in Active Directory with a new password, write out a new keytab, and ensure that it has both "host" and "HTTP" service principals are on it for the hostname.
msktutil --auto-update
This is useful in a daily cron job to check and rotate the password automatically when it's 30 days old.
For users with admin privileges in AD, some common uses:
msktutil --create --service host --service HTTP
This will create a computer account in Active Directory with a new password, write out a new keytab, and ensure that it has both "host" and "HTTP" service principals are on it for the hostname.
msktutil --precreate --host computer1.example.com
This will pre-create an account for computer1 with the default password using your credentials. This can be done on a central host, e.g. to script the addition of many hosts. You can then use msktutil --create on the hosts themselves (without special credentials) to join them to the domain.
msktutil --host afs --service afs --enctypes 0x03
This will create an afs/cell.name@REALM principal, and associate that principal with a computer account called 'afs'. The principal will be marked as DES-only, which is required for AFS.
msktutil --create --use-service-account --service HTTP/hostname.example.com --keytab /etc/apache/krb5.keytab --accountname srv-http --no-pac
This will create an HTTP/hostname.example.com@REALM principal, and associate that principal with a service account called 'srv-http'. Corresponding Kerberos keys will be written to the keytab file /etc/apache/krb5.keytab. The size of Kerberos tickets for that service will stay small because no PAC information will be included.
msktutil --create --service host/hostname --service host/hostname.example.com --set-samba-secret --enctypes 0x4
This will create a computer account in Active Directory that is compatible with Samba. The command creates a new password, write out a new keytab, and ensure that it includes both "host/hostname" and "host/hostname.example.com" as service principals (which is equivalent to what setspn.exe -R would do on windows). The new computer password will be stored in Samba's secrets.tdb database to provide interoperability with Samba. As Samba (version 3) only supports arcfour-encrypted Kerberos tickets the --enctypes option must be used to select only that encryption type.
(C) 2004-2006 Dan Perry <dperry@pppl.gov>
(C) 2006 Brian Elliott Finley (finley@anl.gov)
(C) 2009-2010 Doug Engert (deengert@anl.gov)
(C) 2010 James Knight <foom@fuhm.net>