xref: /freebsd/crypto/krb5/doc/admin/database.rst (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy SchubertDatabase administration
2*7f2fe78bSCy Schubert=======================
3*7f2fe78bSCy Schubert
4*7f2fe78bSCy SchubertA Kerberos database contains all of a realm's Kerberos principals,
5*7f2fe78bSCy Schuberttheir passwords, and other administrative information about each
6*7f2fe78bSCy Schubertprincipal.  For the most part, you will use the :ref:`kdb5_util(8)`
7*7f2fe78bSCy Schubertprogram to manipulate the Kerberos database as a whole, and the
8*7f2fe78bSCy Schubert:ref:`kadmin(1)` program to make changes to the entries in the
9*7f2fe78bSCy Schubertdatabase.  (One notable exception is that users will use the
10*7f2fe78bSCy Schubert:ref:`kpasswd(1)` program to change their own passwords.)  The kadmin
11*7f2fe78bSCy Schubertprogram has its own command-line interface, to which you type the
12*7f2fe78bSCy Schubertdatabase administrating commands.
13*7f2fe78bSCy Schubert
14*7f2fe78bSCy Schubert:ref:`kdb5_util(8)` provides a means to create, delete, load, or dump
15*7f2fe78bSCy Schuberta Kerberos database.  It also contains commands to roll over the
16*7f2fe78bSCy Schubertdatabase master key, and to stash a copy of the key so that the
17*7f2fe78bSCy Schubert:ref:`kadmind(8)` and :ref:`krb5kdc(8)` daemons can use the database
18*7f2fe78bSCy Schubertwithout manual input.
19*7f2fe78bSCy Schubert
20*7f2fe78bSCy Schubert:ref:`kadmin(1)` provides for the maintenance of Kerberos principals,
21*7f2fe78bSCy Schubertpassword policies, and service key tables (keytabs).  Normally it
22*7f2fe78bSCy Schubertoperates as a network client using Kerberos authentication to
23*7f2fe78bSCy Schubertcommunicate with :ref:`kadmind(8)`, but there is also a variant, named
24*7f2fe78bSCy Schubertkadmin.local, which directly accesses the Kerberos database on the
25*7f2fe78bSCy Schubertlocal filesystem (or through LDAP).  kadmin.local is necessary to set
26*7f2fe78bSCy Schubertup enough of the database to be able to use the remote version.
27*7f2fe78bSCy Schubert
28*7f2fe78bSCy Schubertkadmin can authenticate to the admin server using the service
29*7f2fe78bSCy Schubertprincipal ``kadmin/admin`` or ``kadmin/HOST`` (where *HOST* is the
30*7f2fe78bSCy Schuberthostname of the admin server).  If the credentials cache contains a
31*7f2fe78bSCy Schubertticket for either service principal and the **-c** ccache option is
32*7f2fe78bSCy Schubertspecified, that ticket is used to authenticate to KADM5.  Otherwise,
33*7f2fe78bSCy Schubertthe **-p** and **-k** options are used to specify the client Kerberos
34*7f2fe78bSCy Schubertprincipal name used to authenticate.  Once kadmin has determined the
35*7f2fe78bSCy Schubertprincipal name, it requests a ``kadmin/admin`` Kerberos service ticket
36*7f2fe78bSCy Schubertfrom the KDC, and uses that service ticket to authenticate to KADM5.
37*7f2fe78bSCy Schubert
38*7f2fe78bSCy SchubertSee :ref:`kadmin(1)` for the available kadmin and kadmin.local
39*7f2fe78bSCy Schubertcommands and options.
40*7f2fe78bSCy Schubert
41*7f2fe78bSCy Schubert
42*7f2fe78bSCy Schubert.. _principals:
43*7f2fe78bSCy Schubert
44*7f2fe78bSCy SchubertPrincipals
45*7f2fe78bSCy Schubert----------
46*7f2fe78bSCy Schubert
47*7f2fe78bSCy SchubertEach entry in the Kerberos database contains a Kerberos principal and
48*7f2fe78bSCy Schubertthe attributes and policies associated with that principal.
49*7f2fe78bSCy Schubert
50*7f2fe78bSCy SchubertTo add a principal to the database, use the :ref:`kadmin(1)`
51*7f2fe78bSCy Schubert**add_principal** command.  User principals should usually be created
52*7f2fe78bSCy Schubertwith the ``+requires_preauth -allow_svr`` options to help mitigate
53*7f2fe78bSCy Schubertdictionary attacks (see :ref:`dictionary`)::
54*7f2fe78bSCy Schubert
55*7f2fe78bSCy Schubert    kadmin: addprinc +requires_preauth -allow_svr alice
56*7f2fe78bSCy Schubert    Enter password for principal "alice@KRBTEST.COM":
57*7f2fe78bSCy Schubert    Re-enter password for principal "alice@KRBTEST.COM":
58*7f2fe78bSCy Schubert
59*7f2fe78bSCy SchubertUser principals which will authenticate with :ref:`pkinit` should
60*7f2fe78bSCy Schubertinstead by created with the ``-nokey`` option:
61*7f2fe78bSCy Schubert
62*7f2fe78bSCy Schubert    kadmin: addprinc -nokey alice
63*7f2fe78bSCy Schubert
64*7f2fe78bSCy SchubertService principals can be created with the ``-nokey`` option;
65*7f2fe78bSCy Schubertlong-term keys will be added when a keytab is generated::
66*7f2fe78bSCy Schubert
67*7f2fe78bSCy Schubert    kadmin: addprinc -nokey host/foo.mit.edu
68*7f2fe78bSCy Schubert    kadmin: ktadd -k foo.keytab host/foo.mit.edu
69*7f2fe78bSCy Schubert    Entry for principal host/foo.mit.edu with kvno 1, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:foo.keytab.
70*7f2fe78bSCy Schubert    Entry for principal host/foo.mit.edu with kvno 1, encryption type aes128-cts-hmac-sha1-96 added to keytab WRFILE:foo.keytab.
71*7f2fe78bSCy Schubert
72*7f2fe78bSCy SchubertTo modify attributes of an existing principal, use the kadmin
73*7f2fe78bSCy Schubert**modify_principal** command::
74*7f2fe78bSCy Schubert
75*7f2fe78bSCy Schubert    kadmin: modprinc -expire tomorrow alice
76*7f2fe78bSCy Schubert    Principal "alice@KRBTEST.COM" modified.
77*7f2fe78bSCy Schubert
78*7f2fe78bSCy SchubertTo delete a principal, use the kadmin **delete_principal** command::
79*7f2fe78bSCy Schubert
80*7f2fe78bSCy Schubert    kadmin: delprinc alice
81*7f2fe78bSCy Schubert    Are you sure you want to delete the principal "alice@KRBTEST.COM"? (yes/no): yes
82*7f2fe78bSCy Schubert    Principal "alice@KRBTEST.COM" deleted.
83*7f2fe78bSCy Schubert    Make sure that you have removed this principal from all ACLs before reusing.
84*7f2fe78bSCy Schubert
85*7f2fe78bSCy SchubertTo change a principal's password, use the kadmin **change_password**
86*7f2fe78bSCy Schubertcommand.  Password changes made through kadmin are subject to the same
87*7f2fe78bSCy Schubertpassword policies as would apply to password changes made through
88*7f2fe78bSCy Schubert:ref:`kpasswd(1)`.
89*7f2fe78bSCy Schubert
90*7f2fe78bSCy SchubertTo view the attributes of a principal, use the kadmin`
91*7f2fe78bSCy Schubert**get_principal** command.
92*7f2fe78bSCy Schubert
93*7f2fe78bSCy SchubertTo generate a listing of principals, use the kadmin
94*7f2fe78bSCy Schubert**list_principals** command.
95*7f2fe78bSCy Schubert
96*7f2fe78bSCy Schubert
97*7f2fe78bSCy Schubert.. _policies:
98*7f2fe78bSCy Schubert
99*7f2fe78bSCy SchubertPolicies
100*7f2fe78bSCy Schubert--------
101*7f2fe78bSCy Schubert
102*7f2fe78bSCy SchubertA policy is a set of rules governing passwords.  Policies can dictate
103*7f2fe78bSCy Schubertminimum and maximum password lifetimes, minimum number of characters
104*7f2fe78bSCy Schubertand character classes a password must contain, and the number of old
105*7f2fe78bSCy Schubertpasswords kept in the database.
106*7f2fe78bSCy Schubert
107*7f2fe78bSCy SchubertTo add a new policy, use the :ref:`kadmin(1)` **add_policy** command::
108*7f2fe78bSCy Schubert
109*7f2fe78bSCy Schubert    kadmin: addpol -maxlife "1 year" -history 3 stduser
110*7f2fe78bSCy Schubert
111*7f2fe78bSCy SchubertTo modify attributes of a principal, use the kadmin **modify_policy**
112*7f2fe78bSCy Schubertcommand.  To delete a policy, use the kadmin **delete_policy**
113*7f2fe78bSCy Schubertcommand.
114*7f2fe78bSCy Schubert
115*7f2fe78bSCy SchubertTo associate a policy with a principal, use the kadmin
116*7f2fe78bSCy Schubert**modify_principal** command with the **-policy** option:
117*7f2fe78bSCy Schubert
118*7f2fe78bSCy Schubert    kadmin: modprinc -policy stduser alice
119*7f2fe78bSCy Schubert    Principal "alice@KRBTEST.COM" modified.
120*7f2fe78bSCy Schubert
121*7f2fe78bSCy SchubertA principal entry may be associated with a nonexistent policy, either
122*7f2fe78bSCy Schubertbecause the policy did not exist at the time of associated or was
123*7f2fe78bSCy Schubertdeleted afterwards.  kadmin will warn when associated a principal with
124*7f2fe78bSCy Schuberta nonexistent policy, and will annotate the policy name with "[does
125*7f2fe78bSCy Schubertnot exist]" in the **get_principal** output.
126*7f2fe78bSCy Schubert
127*7f2fe78bSCy Schubert
128*7f2fe78bSCy Schubert.. _updating_history_key:
129*7f2fe78bSCy Schubert
130*7f2fe78bSCy SchubertUpdating the history key
131*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~
132*7f2fe78bSCy Schubert
133*7f2fe78bSCy SchubertIf a policy specifies a number of old keys kept of two or more, the
134*7f2fe78bSCy Schubertstored old keys are encrypted in a history key, which is found in the
135*7f2fe78bSCy Schubertkey data of the ``kadmin/history`` principal.
136*7f2fe78bSCy Schubert
137*7f2fe78bSCy SchubertCurrently there is no support for proper rollover of the history key,
138*7f2fe78bSCy Schubertbut you can change the history key (for example, to use a better
139*7f2fe78bSCy Schubertencryption type) at the cost of invalidating currently stored old
140*7f2fe78bSCy Schubertkeys.  To change the history key, run::
141*7f2fe78bSCy Schubert
142*7f2fe78bSCy Schubert    kadmin: change_password -randkey kadmin/history
143*7f2fe78bSCy Schubert
144*7f2fe78bSCy SchubertThis command will fail if you specify the **-keepold** flag.  Only one
145*7f2fe78bSCy Schubertnew history key will be created, even if you specify multiple key/salt
146*7f2fe78bSCy Schubertcombinations.
147*7f2fe78bSCy Schubert
148*7f2fe78bSCy SchubertIn the future, we plan to migrate towards encrypting old keys in the
149*7f2fe78bSCy Schubertmaster key instead of the history key, and implementing proper
150*7f2fe78bSCy Schubertrollover support for stored old keys.
151*7f2fe78bSCy Schubert
152*7f2fe78bSCy Schubert
153*7f2fe78bSCy Schubert.. _privileges:
154*7f2fe78bSCy Schubert
155*7f2fe78bSCy SchubertPrivileges
156*7f2fe78bSCy Schubert----------
157*7f2fe78bSCy Schubert
158*7f2fe78bSCy SchubertAdministrative privileges for the Kerberos database are stored in the
159*7f2fe78bSCy Schubertfile :ref:`kadm5.acl(5)`.
160*7f2fe78bSCy Schubert
161*7f2fe78bSCy Schubert.. note::
162*7f2fe78bSCy Schubert
163*7f2fe78bSCy Schubert          A common use of an admin instance is so you can grant
164*7f2fe78bSCy Schubert          separate permissions (such as administrator access to the
165*7f2fe78bSCy Schubert          Kerberos database) to a separate Kerberos principal. For
166*7f2fe78bSCy Schubert          example, the user ``joeadmin`` might have a principal for
167*7f2fe78bSCy Schubert          his administrative use, called ``joeadmin/admin``.  This
168*7f2fe78bSCy Schubert          way, ``joeadmin`` would obtain ``joeadmin/admin`` tickets
169*7f2fe78bSCy Schubert          only when he actually needs to use those permissions.
170*7f2fe78bSCy Schubert
171*7f2fe78bSCy Schubert
172*7f2fe78bSCy Schubert.. _db_operations:
173*7f2fe78bSCy Schubert
174*7f2fe78bSCy SchubertOperations on the Kerberos database
175*7f2fe78bSCy Schubert-----------------------------------
176*7f2fe78bSCy Schubert
177*7f2fe78bSCy SchubertThe :ref:`kdb5_util(8)` command is the primary tool for administrating
178*7f2fe78bSCy Schubertthe Kerberos database when using the DB2 or LMDB modules (see
179*7f2fe78bSCy Schubert:ref:`dbtypes`).  Creating a database is described in
180*7f2fe78bSCy Schubert:ref:`create_db`.
181*7f2fe78bSCy Schubert
182*7f2fe78bSCy SchubertTo create a stash file using the master password (because the database
183*7f2fe78bSCy Schubertwas not created with one using the ``create -s`` flag, or after
184*7f2fe78bSCy Schubertrestoring from a backup which did not contain the stash file), use the
185*7f2fe78bSCy Schubertkdb5_util **stash** command::
186*7f2fe78bSCy Schubert
187*7f2fe78bSCy Schubert    $ kdb5_util stash
188*7f2fe78bSCy Schubert    kdb5_util: Cannot find/read stored master key while reading master key
189*7f2fe78bSCy Schubert    kdb5_util: Warning: proceeding without master key
190*7f2fe78bSCy Schubert    Enter KDC database master key:  <= Type the KDC database master password.
191*7f2fe78bSCy Schubert
192*7f2fe78bSCy SchubertTo destroy a database, use the kdb5_util destroy command::
193*7f2fe78bSCy Schubert
194*7f2fe78bSCy Schubert    $ kdb5_util destroy
195*7f2fe78bSCy Schubert    Deleting KDC database stored in '/var/krb5kdc/principal', are you sure?
196*7f2fe78bSCy Schubert    (type 'yes' to confirm)? yes
197*7f2fe78bSCy Schubert    OK, deleting database '/var/krb5kdc/principal'...
198*7f2fe78bSCy Schubert    ** Database '/var/krb5kdc/principal' destroyed.
199*7f2fe78bSCy Schubert
200*7f2fe78bSCy Schubert
201*7f2fe78bSCy Schubert.. _restore_from_dump:
202*7f2fe78bSCy Schubert
203*7f2fe78bSCy SchubertDumping and loading a Kerberos database
204*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205*7f2fe78bSCy Schubert
206*7f2fe78bSCy SchubertTo dump a Kerberos database into a text file for backup or transfer
207*7f2fe78bSCy Schubertpurposes, use the :ref:`kdb5_util(8)` **dump** command on one of the
208*7f2fe78bSCy SchubertKDCs::
209*7f2fe78bSCy Schubert
210*7f2fe78bSCy Schubert    $ kdb5_util dump dumpfile
211*7f2fe78bSCy Schubert
212*7f2fe78bSCy Schubert    $ kbd5_util dump -verbose dumpfile
213*7f2fe78bSCy Schubert    kadmin/admin@ATHENA.MIT.EDU
214*7f2fe78bSCy Schubert    krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
215*7f2fe78bSCy Schubert    kadmin/history@ATHENA.MIT.EDU
216*7f2fe78bSCy Schubert    K/M@ATHENA.MIT.EDU
217*7f2fe78bSCy Schubert    kadmin/changepw@ATHENA.MIT.EDU
218*7f2fe78bSCy Schubert
219*7f2fe78bSCy SchubertYou may specify which principals to dump, using full principal names
220*7f2fe78bSCy Schubertincluding realm::
221*7f2fe78bSCy Schubert
222*7f2fe78bSCy Schubert    $ kdb5_util dump -verbose someprincs K/M@ATHENA.MIT.EDU kadmin/admin@ATHENA.MIT.EDU
223*7f2fe78bSCy Schubert    kadmin/admin@ATHENA.MIT.EDU
224*7f2fe78bSCy Schubert    K/M@ATHENA.MIT.EDU
225*7f2fe78bSCy Schubert
226*7f2fe78bSCy SchubertTo restore a Kerberos database dump from a file, use the
227*7f2fe78bSCy Schubert:ref:`kdb5_util(8)` **load** command::
228*7f2fe78bSCy Schubert
229*7f2fe78bSCy Schubert    $ kdb5_util load dumpfile
230*7f2fe78bSCy Schubert
231*7f2fe78bSCy SchubertTo update an existing database with a partial dump file containing
232*7f2fe78bSCy Schubertonly some principals, use the ``-update`` flag::
233*7f2fe78bSCy Schubert
234*7f2fe78bSCy Schubert    $ kdb5_util load -update someprincs
235*7f2fe78bSCy Schubert
236*7f2fe78bSCy Schubert.. note::
237*7f2fe78bSCy Schubert
238*7f2fe78bSCy Schubert          If the database file exists, and the *-update* flag was not
239*7f2fe78bSCy Schubert          given, *kdb5_util* will overwrite the existing database.
240*7f2fe78bSCy Schubert
241*7f2fe78bSCy Schubert
242*7f2fe78bSCy Schubert.. _updating_master_key:
243*7f2fe78bSCy Schubert
244*7f2fe78bSCy SchubertUpdating the master key
245*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~
246*7f2fe78bSCy Schubert
247*7f2fe78bSCy SchubertStarting with release 1.7, :ref:`kdb5_util(8)` allows the master key
248*7f2fe78bSCy Schubertto be changed using a rollover process, with minimal loss of
249*7f2fe78bSCy Schubertavailability.  To roll over the master key, follow these steps:
250*7f2fe78bSCy Schubert
251*7f2fe78bSCy Schubert#. On the primary KDC, run ``kdb5_util list_mkeys`` to view the
252*7f2fe78bSCy Schubert   current master key version number (KVNO).  If you have never rolled
253*7f2fe78bSCy Schubert   over the master key before, this will likely be version 1::
254*7f2fe78bSCy Schubert
255*7f2fe78bSCy Schubert    $ kdb5_util list_mkeys
256*7f2fe78bSCy Schubert    Master keys for Principal: K/M@KRBTEST.COM
257*7f2fe78bSCy Schubert    KVNO: 1, Enctype: aes256-cts-hmac-sha384-192, Active on: Thu Jan 01 00:00:00 UTC 1970 *
258*7f2fe78bSCy Schubert
259*7f2fe78bSCy Schubert#. On the primary KDC, run ``kdb5_util use_mkey 1`` to ensure that a
260*7f2fe78bSCy Schubert   master key activation list is present in the database.  This step
261*7f2fe78bSCy Schubert   is unnecessary in release 1.11.4 or later, or if the database was
262*7f2fe78bSCy Schubert   initially created with release 1.7 or later.
263*7f2fe78bSCy Schubert
264*7f2fe78bSCy Schubert#. On the primary KDC, run ``kdb5_util add_mkey -s`` to create a new
265*7f2fe78bSCy Schubert   master key and write it to the stash file.  Enter a secure password
266*7f2fe78bSCy Schubert   when prompted.  If this is the first time you are changing the
267*7f2fe78bSCy Schubert   master key, the new key will have version 2.  The new master key
268*7f2fe78bSCy Schubert   will not be used until you make it active.
269*7f2fe78bSCy Schubert
270*7f2fe78bSCy Schubert#. Propagate the database to all replica KDCs, either manually or by
271*7f2fe78bSCy Schubert   waiting until the next scheduled propagation.  If you do not have
272*7f2fe78bSCy Schubert   any replica KDCs, you can skip this and the next step.
273*7f2fe78bSCy Schubert
274*7f2fe78bSCy Schubert#. On each replica KDC, run ``kdb5_util list_mkeys`` to verify that
275*7f2fe78bSCy Schubert   the new master key is present, and then ``kdb5_util stash`` to
276*7f2fe78bSCy Schubert   write the new master key to the replica KDC's stash file.
277*7f2fe78bSCy Schubert
278*7f2fe78bSCy Schubert#. On the primary KDC, run ``kdb5_util use_mkey 2`` to begin using the
279*7f2fe78bSCy Schubert   new master key.  Replace ``2`` with the version of the new master
280*7f2fe78bSCy Schubert   key, as appropriate.  You can optionally specify a date for the new
281*7f2fe78bSCy Schubert   master key to become active; by default, it will become active
282*7f2fe78bSCy Schubert   immediately.  Prior to release 1.12, :ref:`kadmind(8)` must be
283*7f2fe78bSCy Schubert   restarted for this change to take full effect.
284*7f2fe78bSCy Schubert
285*7f2fe78bSCy Schubert#. On the primary KDC, run ``kdb5_util update_princ_encryption``.
286*7f2fe78bSCy Schubert   This command will iterate over the database and re-encrypt all keys
287*7f2fe78bSCy Schubert   in the new master key.  If the database is large and uses DB2, the
288*7f2fe78bSCy Schubert   primary KDC will become unavailable while this command runs, but
289*7f2fe78bSCy Schubert   clients should fail over to replica KDCs (if any are present)
290*7f2fe78bSCy Schubert   during this time period.  In release 1.13 and later, you can
291*7f2fe78bSCy Schubert   instead run ``kdb5_util -x unlockiter update_princ_encryption`` to
292*7f2fe78bSCy Schubert   use unlocked iteration; this variant will take longer, but will
293*7f2fe78bSCy Schubert   keep the database available to the KDC and kadmind while it runs.
294*7f2fe78bSCy Schubert
295*7f2fe78bSCy Schubert#. Wait until the above changes have propagated to all replica KDCs
296*7f2fe78bSCy Schubert   and until all running KDC and kadmind processes have serviced
297*7f2fe78bSCy Schubert   requests using updated principal entries.
298*7f2fe78bSCy Schubert
299*7f2fe78bSCy Schubert#. On the primary KDC, run ``kdb5_util purge_mkeys`` to clean up the
300*7f2fe78bSCy Schubert   old master key.
301*7f2fe78bSCy Schubert
302*7f2fe78bSCy Schubert
303*7f2fe78bSCy Schubert.. _ops_on_ldap:
304*7f2fe78bSCy Schubert
305*7f2fe78bSCy SchubertOperations on the LDAP database
306*7f2fe78bSCy Schubert-------------------------------
307*7f2fe78bSCy Schubert
308*7f2fe78bSCy SchubertThe :ref:`kdb5_ldap_util(8)` command is the primary tool for
309*7f2fe78bSCy Schubertadministrating the Kerberos database when using the LDAP module.
310*7f2fe78bSCy SchubertCreating an LDAP Kerberos database is describe in :ref:`conf_ldap`.
311*7f2fe78bSCy Schubert
312*7f2fe78bSCy SchubertTo view a list of realms in the LDAP database, use the kdb5_ldap_util
313*7f2fe78bSCy Schubert**list** command::
314*7f2fe78bSCy Schubert
315*7f2fe78bSCy Schubert    $ kdb5_ldap_util list
316*7f2fe78bSCy Schubert    KRBTEST.COM
317*7f2fe78bSCy Schubert
318*7f2fe78bSCy SchubertTo modify the attributes of a realm, use the kdb5_ldap_util **modify**
319*7f2fe78bSCy Schubertcommand.  For example, to change the default realm's maximum ticket
320*7f2fe78bSCy Schubertlife::
321*7f2fe78bSCy Schubert
322*7f2fe78bSCy Schubert    $ kdb5_ldap_util modify -maxtktlife "10 hours"
323*7f2fe78bSCy Schubert
324*7f2fe78bSCy SchubertTo display the attributes of a realm, use the kdb5_ldap_util **view**
325*7f2fe78bSCy Schubertcommand::
326*7f2fe78bSCy Schubert
327*7f2fe78bSCy Schubert    $ kdb5_ldap_util view
328*7f2fe78bSCy Schubert                   Realm Name: KRBTEST.COM
329*7f2fe78bSCy Schubert          Maximum Ticket Life: 0 days 00:10:00
330*7f2fe78bSCy Schubert
331*7f2fe78bSCy SchubertTo remove a realm from the LDAP database, destroying its contents, use
332*7f2fe78bSCy Schubertthe kdb5_ldap_util **destroy** command::
333*7f2fe78bSCy Schubert
334*7f2fe78bSCy Schubert    $ kdb5_ldap_util destroy
335*7f2fe78bSCy Schubert    Deleting KDC database of 'KRBTEST.COM', are you sure?
336*7f2fe78bSCy Schubert    (type 'yes' to confirm)? yes
337*7f2fe78bSCy Schubert    OK, deleting database of 'KRBTEST.COM'...
338*7f2fe78bSCy Schubert    ** Database of 'KRBTEST.COM' destroyed.
339*7f2fe78bSCy Schubert
340*7f2fe78bSCy Schubert
341*7f2fe78bSCy SchubertTicket Policy operations
342*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~
343*7f2fe78bSCy Schubert
344*7f2fe78bSCy SchubertUnlike the DB2 and LMDB modules, the LDAP module supports ticket
345*7f2fe78bSCy Schubertpolicy objects, which can be associated with principals to restrict
346*7f2fe78bSCy Schubertmaximum ticket lifetimes and set mandatory principal flags.  Ticket
347*7f2fe78bSCy Schubertpolicy objects are distinct from the password policies described
348*7f2fe78bSCy Schubertearlier on this page, and are chiefly managed through kdb5_ldap_util
349*7f2fe78bSCy Schubertrather than kadmin.  To create a new ticket policy, use the
350*7f2fe78bSCy Schubertkdb5_ldap_util **create_policy** command::
351*7f2fe78bSCy Schubert
352*7f2fe78bSCy Schubert    $ kdb5_ldap_util create_policy -maxrenewlife "2 days" users
353*7f2fe78bSCy Schubert
354*7f2fe78bSCy SchubertTo associate a ticket policy with a principal, use the
355*7f2fe78bSCy Schubert:ref:`kadmin(1)` **modify_principal** (or **add_principal**) command
356*7f2fe78bSCy Schubertwith the **-x tktpolicy=**\ *policy* option::
357*7f2fe78bSCy Schubert
358*7f2fe78bSCy Schubert    $ kadmin.local modprinc -x tktpolicy=users alice
359*7f2fe78bSCy Schubert
360*7f2fe78bSCy SchubertTo remove a ticket policy reference from a principal, use the same
361*7f2fe78bSCy Schubertcommand with an empty *policy*::
362*7f2fe78bSCy Schubert
363*7f2fe78bSCy Schubert    $ kadmin.local modprinc -x tktpolicy= alice
364*7f2fe78bSCy Schubert
365*7f2fe78bSCy SchubertTo list the existing ticket policy objects, use the kdb5_ldap_util
366*7f2fe78bSCy Schubert**list_policy** command::
367*7f2fe78bSCy Schubert
368*7f2fe78bSCy Schubert    $ kdb5_ldap_util list_policy
369*7f2fe78bSCy Schubert    users
370*7f2fe78bSCy Schubert
371*7f2fe78bSCy SchubertTo modify the attributes of a ticket policy object, use the
372*7f2fe78bSCy Schubertkdb5_ldap_util **modify_policy** command::
373*7f2fe78bSCy Schubert
374*7f2fe78bSCy Schubert    $ kdb5_ldap_util modify_policy -allow_svr +requires_preauth users
375*7f2fe78bSCy Schubert
376*7f2fe78bSCy SchubertTo view the attributes of a ticket policy object, use the
377*7f2fe78bSCy Schubertkdb5_ldap_util **view_policy** command::
378*7f2fe78bSCy Schubert
379*7f2fe78bSCy Schubert    $ kdb5_ldap_util view_policy users
380*7f2fe78bSCy Schubert                Ticket policy: users
381*7f2fe78bSCy Schubert       Maximum renewable life: 2 days 00:00:00
382*7f2fe78bSCy Schubert                 Ticket flags: REQUIRES_PRE_AUTH DISALLOW_SVR
383*7f2fe78bSCy Schubert
384*7f2fe78bSCy SchubertTo destroy an ticket policy object, use the kdb5_ldap_util
385*7f2fe78bSCy Schubert**destroy_policy** command::
386*7f2fe78bSCy Schubert
387*7f2fe78bSCy Schubert    $ kdb5_ldap_util destroy_policy users
388*7f2fe78bSCy Schubert    This will delete the policy object 'users', are you sure?
389*7f2fe78bSCy Schubert    (type 'yes' to confirm)? yes
390*7f2fe78bSCy Schubert    ** policy object 'users' deleted.
391*7f2fe78bSCy Schubert
392*7f2fe78bSCy Schubert
393*7f2fe78bSCy Schubert.. _xrealm_authn:
394*7f2fe78bSCy Schubert
395*7f2fe78bSCy SchubertCross-realm authentication
396*7f2fe78bSCy Schubert--------------------------
397*7f2fe78bSCy Schubert
398*7f2fe78bSCy SchubertIn order for a KDC in one realm to authenticate Kerberos users in a
399*7f2fe78bSCy Schubertdifferent realm, it must share a key with the KDC in the other realm.
400*7f2fe78bSCy SchubertIn both databases, there must be krbtgt service principals for both realms.
401*7f2fe78bSCy SchubertFor example, if you need to do cross-realm authentication between the realms
402*7f2fe78bSCy Schubert``ATHENA.MIT.EDU`` and ``EXAMPLE.COM``, you would need to add the
403*7f2fe78bSCy Schubertprincipals ``krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU`` and
404*7f2fe78bSCy Schubert``krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM`` to both databases.
405*7f2fe78bSCy SchubertThese principals must all have the same passwords, key version
406*7f2fe78bSCy Schubertnumbers, and encryption types; this may require explicitly setting
407*7f2fe78bSCy Schubertthe key version number with the **-kvno** option.
408*7f2fe78bSCy Schubert
409*7f2fe78bSCy SchubertIn the ATHENA.MIT.EDU and EXAMPLE.COM cross-realm case, the administrators
410*7f2fe78bSCy Schubertwould run the following commands on the KDCs in both realms::
411*7f2fe78bSCy Schubert
412*7f2fe78bSCy Schubert    shell%: kadmin.local -e "aes256-cts:normal"
413*7f2fe78bSCy Schubert    kadmin: addprinc -requires_preauth krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM
414*7f2fe78bSCy Schubert    Enter password for principal krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM:
415*7f2fe78bSCy Schubert    Re-enter password for principal krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM:
416*7f2fe78bSCy Schubert    kadmin: addprinc -requires_preauth krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU
417*7f2fe78bSCy Schubert    Enter password for principal krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU:
418*7f2fe78bSCy Schubert    Enter password for principal krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU:
419*7f2fe78bSCy Schubert    kadmin:
420*7f2fe78bSCy Schubert
421*7f2fe78bSCy Schubert.. note::
422*7f2fe78bSCy Schubert
423*7f2fe78bSCy Schubert          Even if most principals in a realm are generally created
424*7f2fe78bSCy Schubert          with the **requires_preauth** flag enabled, this flag is not
425*7f2fe78bSCy Schubert          desirable on cross-realm authentication keys because doing
426*7f2fe78bSCy Schubert          so makes it impossible to disable preauthentication on a
427*7f2fe78bSCy Schubert          service-by-service basis.  Disabling it as in the example
428*7f2fe78bSCy Schubert          above is recommended.
429*7f2fe78bSCy Schubert
430*7f2fe78bSCy Schubert.. note::
431*7f2fe78bSCy Schubert
432*7f2fe78bSCy Schubert          It is very important that these principals have good
433*7f2fe78bSCy Schubert          passwords.  MIT recommends that TGT principal passwords be
434*7f2fe78bSCy Schubert          at least 26 characters of random ASCII text.
435*7f2fe78bSCy Schubert
436*7f2fe78bSCy Schubert
437*7f2fe78bSCy Schubert.. _changing_krbtgt_key:
438*7f2fe78bSCy Schubert
439*7f2fe78bSCy SchubertChanging the krbtgt key
440*7f2fe78bSCy Schubert-----------------------
441*7f2fe78bSCy Schubert
442*7f2fe78bSCy SchubertA Kerberos Ticket Granting Ticket (TGT) is a service ticket for the
443*7f2fe78bSCy Schubertprincipal ``krbtgt/REALM``.  The key for this principal is created
444*7f2fe78bSCy Schubertwhen the Kerberos database is initialized and need not be changed.
445*7f2fe78bSCy SchubertHowever, it will only have the encryption types supported by the KDC
446*7f2fe78bSCy Schubertat the time of the initial database creation.  To allow use of newer
447*7f2fe78bSCy Schubertencryption types for the TGT, this key has to be changed.
448*7f2fe78bSCy Schubert
449*7f2fe78bSCy SchubertChanging this key using the normal :ref:`kadmin(1)`
450*7f2fe78bSCy Schubert**change_password** command would invalidate any previously issued
451*7f2fe78bSCy SchubertTGTs.  Therefore, when changing this key, normally one should use the
452*7f2fe78bSCy Schubert**-keepold** flag to change_password to retain the previous key in the
453*7f2fe78bSCy Schubertdatabase as well as the new key.  For example::
454*7f2fe78bSCy Schubert
455*7f2fe78bSCy Schubert    kadmin: change_password -randkey -keepold krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
456*7f2fe78bSCy Schubert
457*7f2fe78bSCy Schubert.. warning::
458*7f2fe78bSCy Schubert
459*7f2fe78bSCy Schubert             After issuing this command, the old key is still valid
460*7f2fe78bSCy Schubert             and is still vulnerable to (for instance) brute force
461*7f2fe78bSCy Schubert             attacks.  To completely retire an old key or encryption
462*7f2fe78bSCy Schubert             type, run the kadmin **purgekeys** command to delete keys
463*7f2fe78bSCy Schubert             with older kvnos, ideally first making sure that all
464*7f2fe78bSCy Schubert             tickets issued with the old keys have expired.
465*7f2fe78bSCy Schubert
466*7f2fe78bSCy SchubertOnly the first krbtgt key of the newest key version is used to encrypt
467*7f2fe78bSCy Schubertticket-granting tickets.  However, the set of encryption types present
468*7f2fe78bSCy Schubertin the krbtgt keys is used by default to determine the session key
469*7f2fe78bSCy Schuberttypes supported by the krbtgt service (see
470*7f2fe78bSCy Schubert:ref:`session_key_selection`).  Because non-MIT Kerberos clients
471*7f2fe78bSCy Schubertsometimes send a limited set of encryption types when making AS
472*7f2fe78bSCy Schubertrequests, it can be important for the krbtgt service to support
473*7f2fe78bSCy Schubertmultiple encryption types.  This can be accomplished by giving the
474*7f2fe78bSCy Schubertkrbtgt principal multiple keys, which is usually as simple as not
475*7f2fe78bSCy Schubertspecifying any **-e** option when changing the krbtgt key, or by
476*7f2fe78bSCy Schubertsetting the **session_enctypes** string attribute on the krbtgt
477*7f2fe78bSCy Schubertprincipal (see :ref:`set_string`).
478*7f2fe78bSCy Schubert
479*7f2fe78bSCy SchubertDue to a bug in releases 1.8 through 1.13, renewed and forwarded
480*7f2fe78bSCy Schuberttickets may not work if the original ticket was obtained prior to a
481*7f2fe78bSCy Schubertkrbtgt key change and the modified ticket is obtained afterwards.
482*7f2fe78bSCy SchubertUpgrading the KDC to release 1.14 or later will correct this bug.
483*7f2fe78bSCy Schubert
484*7f2fe78bSCy Schubert
485*7f2fe78bSCy Schubert.. _incr_db_prop:
486*7f2fe78bSCy Schubert
487*7f2fe78bSCy SchubertIncremental database propagation
488*7f2fe78bSCy Schubert--------------------------------
489*7f2fe78bSCy Schubert
490*7f2fe78bSCy SchubertOverview
491*7f2fe78bSCy Schubert~~~~~~~~
492*7f2fe78bSCy Schubert
493*7f2fe78bSCy SchubertAt some very large sites, dumping and transmitting the database can
494*7f2fe78bSCy Schuberttake more time than is desirable for changes to propagate from the
495*7f2fe78bSCy Schubertprimary KDC to the replica KDCs.  The incremental propagation support
496*7f2fe78bSCy Schubertadded in the 1.7 release is intended to address this.
497*7f2fe78bSCy Schubert
498*7f2fe78bSCy SchubertWith incremental propagation enabled, all programs on the primary KDC
499*7f2fe78bSCy Schubertthat change the database also write information about the changes to
500*7f2fe78bSCy Schubertan "update log" file, maintained as a circular buffer of a certain
501*7f2fe78bSCy Schubertsize.  A process on each replica KDC connects to a service on the
502*7f2fe78bSCy Schubertprimary KDC (currently implemented in the :ref:`kadmind(8)` server) and
503*7f2fe78bSCy Schubertperiodically requests the changes that have been made since the last
504*7f2fe78bSCy Schubertcheck.  By default, this check is done every two minutes.
505*7f2fe78bSCy Schubert
506*7f2fe78bSCy SchubertIncremental propagation uses the following entries in the per-realm
507*7f2fe78bSCy Schubertdata in the KDC config file (See :ref:`kdc.conf(5)`):
508*7f2fe78bSCy Schubert
509*7f2fe78bSCy Schubert====================== =============== ===========================================
510*7f2fe78bSCy Schubertiprop_enable           *boolean*       If *true*, then incremental propagation is enabled, and (as noted below) normal kprop propagation is disabled. The default is *false*.
511*7f2fe78bSCy Schubertiprop_master_ulogsize  *integer*       Indicates the number of entries that should be retained in the update log. The default is 1000; the maximum number is 2500.
512*7f2fe78bSCy Schubertiprop_replica_poll     *time interval* Indicates how often the replica should poll the primary KDC for changes to the database. The default is two minutes.
513*7f2fe78bSCy Schubertiprop_port             *integer*       Specifies the port number to be used for incremental propagation. This is required in both primary and replica configuration files.
514*7f2fe78bSCy Schubertiprop_resync_timeout   *integer*       Specifies the number of seconds to wait for a full propagation to complete. This is optional on replica configurations.  Defaults to 300 seconds (5 minutes).
515*7f2fe78bSCy Schubertiprop_logfile          *file name*     Specifies where the update log file for the realm database is to be stored. The default is to use the *database_name* entry from the realms section of the config file :ref:`kdc.conf(5)`, with *.ulog* appended. (NOTE: If database_name isn't specified in the realms section, perhaps because the LDAP database back end is being used, or the file name is specified in the *dbmodules* section, then the hard-coded default for *database_name* is used. Determination of the *iprop_logfile*  default value will not use values from the *dbmodules* section.)
516*7f2fe78bSCy Schubert====================== =============== ===========================================
517*7f2fe78bSCy Schubert
518*7f2fe78bSCy SchubertBoth primary and replica sides must have a principal named
519*7f2fe78bSCy Schubert``kiprop/hostname`` (where *hostname* is the lowercase,
520*7f2fe78bSCy Schubertfully-qualified, canonical name for the host) registered in the
521*7f2fe78bSCy SchubertKerberos database, and have keys for that principal stored in the
522*7f2fe78bSCy Schubertdefault keytab file (|keytab|).  The ``kiprop/hostname`` principal may
523*7f2fe78bSCy Schuberthave been created automatically for the primary KDC, but it must
524*7f2fe78bSCy Schubertalways be created for replica KDCs.
525*7f2fe78bSCy Schubert
526*7f2fe78bSCy SchubertOn the primary KDC side, the ``kiprop/hostname`` principal must be
527*7f2fe78bSCy Schubertlisted in the kadmind ACL file :ref:`kadm5.acl(5)`, and given the
528*7f2fe78bSCy Schubert**p** privilege (see :ref:`privileges`).
529*7f2fe78bSCy Schubert
530*7f2fe78bSCy SchubertOn the replica KDC side, :ref:`kpropd(8)` should be run.  When
531*7f2fe78bSCy Schubertincremental propagation is enabled, it will connect to the kadmind on
532*7f2fe78bSCy Schubertthe primary KDC and start requesting updates.
533*7f2fe78bSCy Schubert
534*7f2fe78bSCy SchubertThe normal kprop mechanism is disabled by the incremental propagation
535*7f2fe78bSCy Schubertsupport.  However, if the replica has been unable to fetch changes
536*7f2fe78bSCy Schubertfrom the primary KDC for too long (network problems, perhaps), the log
537*7f2fe78bSCy Schuberton the primary may wrap around and overwrite some of the updates that
538*7f2fe78bSCy Schubertthe replica has not yet retrieved.  In this case, the replica will
539*7f2fe78bSCy Schubertinstruct the primary KDC to dump the current database out to a file
540*7f2fe78bSCy Schubertand invoke a one-time kprop propagation, with special options to also
541*7f2fe78bSCy Schubertconvey the point in the update log at which the replica should resume
542*7f2fe78bSCy Schubertfetching incremental updates.  Thus, all the keytab and ACL setup
543*7f2fe78bSCy Schubertpreviously described for kprop propagation is still needed.
544*7f2fe78bSCy Schubert
545*7f2fe78bSCy SchubertIf an environment has a large number of replicas, it may be desirable
546*7f2fe78bSCy Schubertto arrange them in a hierarchy instead of having the primary serve
547*7f2fe78bSCy Schubertupdates to every replica.  To do this, run ``kadmind -proponly`` on
548*7f2fe78bSCy Schuberteach intermediate replica, and ``kpropd -A upstreamhostname`` on
549*7f2fe78bSCy Schubertdownstream replicas to direct each one to the appropriate upstream
550*7f2fe78bSCy Schubertreplica.
551*7f2fe78bSCy Schubert
552*7f2fe78bSCy SchubertThere are several known restrictions in the current implementation:
553*7f2fe78bSCy Schubert
554*7f2fe78bSCy Schubert- The incremental update protocol does not transport changes to policy
555*7f2fe78bSCy Schubert  objects.  Any policy changes on the primary will result in full
556*7f2fe78bSCy Schubert  resyncs to all replicas.
557*7f2fe78bSCy Schubert- The replica's KDB module must support locking; it cannot be using the
558*7f2fe78bSCy Schubert  LDAP KDB module.
559*7f2fe78bSCy Schubert- The primary and replica must be able to initiate TCP connections in
560*7f2fe78bSCy Schubert  both directions, without an intervening NAT.
561*7f2fe78bSCy Schubert
562*7f2fe78bSCy Schubert
563*7f2fe78bSCy SchubertSun/MIT incremental propagation differences
564*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
565*7f2fe78bSCy Schubert
566*7f2fe78bSCy SchubertSun donated the original code for supporting incremental database
567*7f2fe78bSCy Schubertpropagation to MIT.  Some changes have been made in the MIT source
568*7f2fe78bSCy Schuberttree that will be visible to administrators.  (These notes are based
569*7f2fe78bSCy Schuberton Sun's patches.  Changes to Sun's implementation since then may not
570*7f2fe78bSCy Schubertbe reflected here.)
571*7f2fe78bSCy Schubert
572*7f2fe78bSCy SchubertThe Sun config file support looks for ``sunw_dbprop_enable``,
573*7f2fe78bSCy Schubert``sunw_dbprop_master_ulogsize``, and ``sunw_dbprop_slave_poll``.
574*7f2fe78bSCy Schubert
575*7f2fe78bSCy SchubertThe incremental propagation service is implemented as an ONC RPC
576*7f2fe78bSCy Schubertservice.  In the Sun implementation, the service is registered with
577*7f2fe78bSCy Schubertrpcbind (also known as portmapper) and the client looks up the port
578*7f2fe78bSCy Schubertnumber to contact.  In the MIT implementation, where interaction with
579*7f2fe78bSCy Schubertsome modern versions of rpcbind doesn't always work well, the port
580*7f2fe78bSCy Schubertnumber must be specified in the config file on both the primary and
581*7f2fe78bSCy Schubertreplica sides.
582*7f2fe78bSCy Schubert
583*7f2fe78bSCy SchubertThe Sun implementation hard-codes pathnames in ``/var/krb5`` for the
584*7f2fe78bSCy Schubertupdate log and the per-replica kprop dump files.  In the MIT
585*7f2fe78bSCy Schubertimplementation, the pathname for the update log is specified in the
586*7f2fe78bSCy Schubertconfig file, and the per-replica dump files are stored in
587*7f2fe78bSCy Schubert|kdcdir|\ ``/replica_datatrans_hostname``.
588