1Database administration
2=======================
3
4A Kerberos database contains all of a realm's Kerberos principals,
5their passwords, and other administrative information about each
6principal.  For the most part, you will use the :ref:`kdb5_util(8)`
7program to manipulate the Kerberos database as a whole, and the
8:ref:`kadmin(1)` program to make changes to the entries in the
9database.  (One notable exception is that users will use the
10:ref:`kpasswd(1)` program to change their own passwords.)  The kadmin
11program has its own command-line interface, to which you type the
12database administrating commands.
13
14:ref:`kdb5_util(8)` provides a means to create, delete, load, or dump
15a Kerberos database.  It also contains commands to roll over the
16database master key, and to stash a copy of the key so that the
17:ref:`kadmind(8)` and :ref:`krb5kdc(8)` daemons can use the database
18without manual input.
19
20:ref:`kadmin(1)` provides for the maintenance of Kerberos principals,
21password policies, and service key tables (keytabs).  Normally it
22operates as a network client using Kerberos authentication to
23communicate with :ref:`kadmind(8)`, but there is also a variant, named
24kadmin.local, which directly accesses the Kerberos database on the
25local filesystem (or through LDAP).  kadmin.local is necessary to set
26up enough of the database to be able to use the remote version.
27
28kadmin can authenticate to the admin server using the service
29principal ``kadmin/admin`` or ``kadmin/HOST`` (where *HOST* is the
30hostname of the admin server).  If the credentials cache contains a
31ticket for either service principal and the **-c** ccache option is
32specified, that ticket is used to authenticate to KADM5.  Otherwise,
33the **-p** and **-k** options are used to specify the client Kerberos
34principal name used to authenticate.  Once kadmin has determined the
35principal name, it requests a ``kadmin/admin`` Kerberos service ticket
36from the KDC, and uses that service ticket to authenticate to KADM5.
37
38See :ref:`kadmin(1)` for the available kadmin and kadmin.local
39commands and options.
40
41
42kadmin options
43--------------
44
45You can invoke :ref:`kadmin(1)` or kadmin.local with any of the
46following options:
47
48.. include:: admin_commands/kadmin_local.rst
49   :start-after:  kadmin_synopsis:
50   :end-before: kadmin_synopsis_end:
51
52**OPTIONS**
53
54.. include:: admin_commands/kadmin_local.rst
55   :start-after:  _kadmin_options:
56   :end-before: _kadmin_options_end:
57
58
59Date Format
60-----------
61
62For the supported date-time formats see :ref:`getdate` section
63in :ref:`datetime`.
64
65
66Principals
67----------
68
69Each entry in the Kerberos database contains a Kerberos principal and
70the attributes and policies associated with that principal.
71
72
73.. _add_mod_del_princs:
74
75Adding, modifying and deleting principals
76~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77
78To add a principal to the database, use the :ref:`kadmin(1)`
79**add_principal** command.
80
81To modify attributes of a principal, use the kadmin
82**modify_principal** command.
83
84To delete a principal, use the kadmin **delete_principal** command.
85
86.. include:: admin_commands/kadmin_local.rst
87   :start-after:  _add_principal:
88   :end-before: _add_principal_end:
89
90.. include:: admin_commands/kadmin_local.rst
91   :start-after:  _modify_principal:
92   :end-before: _modify_principal_end:
93
94.. include:: admin_commands/kadmin_local.rst
95   :start-after:  _delete_principal:
96   :end-before: _delete_principal_end:
97
98
99Examples
100########
101
102If you want to create a principal which is contained by a LDAP object,
103all you need to do is::
104
105    kadmin: addprinc -x dn=cn=jennifer,dc=example,dc=com jennifer
106    No policy specified for "jennifer@ATHENA.MIT.EDU";
107    defaulting to no policy.
108    Enter password for principal jennifer@ATHENA.MIT.EDU:  <= Type the password.
109    Re-enter password for principal jennifer@ATHENA.MIT.EDU:  <=Type it again.
110    Principal "jennifer@ATHENA.MIT.EDU" created.
111    kadmin:
112
113If you want to create a principal under a specific LDAP container and
114link to an existing LDAP object, all you need to do is::
115
116    kadmin: addprinc -x containerdn=dc=example,dc=com -x linkdn=cn=david,dc=example,dc=com david
117    No policy specified for "david@ATHENA.MIT.EDU";
118    defaulting to no policy.
119    Enter password for principal david@ATHENA.MIT.EDU:  <= Type the password.
120    Re-enter password for principal david@ATHENA.MIT.EDU:  <=Type it again.
121    Principal "david@ATHENA.MIT.EDU" created.
122    kadmin:
123
124If you want to associate a ticket policy to a principal, all you need
125to do is::
126
127    kadmin: modprinc -x tktpolicy=userpolicy david
128    Principal "david@ATHENA.MIT.EDU" modified.
129    kadmin:
130
131If, on the other hand, you want to set up an account that expires on
132January 1, 2000, that uses a policy called "stduser", with a temporary
133password (which you want the user to change immediately), you would
134type the following::
135
136    kadmin: addprinc david -expire "1/1/2000 12:01am EST" -policy stduser +needchange
137    Enter password for principal david@ATHENA.MIT.EDU:  <= Type the password.
138    Re-enter password for principal
139    david@ATHENA.MIT.EDU:  <= Type it again.
140    Principal "david@ATHENA.MIT.EDU" created.
141    kadmin:
142
143If you want to delete a principal::
144
145    kadmin: delprinc jennifer
146    Are you sure you want to delete the principal
147    "jennifer@ATHENA.MIT.EDU"? (yes/no): yes
148    Principal "jennifer@ATHENA.MIT.EDU" deleted.
149    Make sure that you have removed this principal from
150    all ACLs before reusing.
151    kadmin:
152
153
154Retrieving information about a principal
155~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156
157To retrieve a listing of the attributes and/or policies associated
158with a principal, use the :ref:`kadmin(1)` **get_principal** command.
159
160To generate a listing of principals, use the kadmin
161**list_principals** command.
162
163.. include:: admin_commands/kadmin_local.rst
164   :start-after:  _get_principal:
165   :end-before: _get_principal_end:
166
167.. include:: admin_commands/kadmin_local.rst
168   :start-after:  _list_principals:
169   :end-before: _list_principals_end:
170
171
172Changing passwords
173~~~~~~~~~~~~~~~~~~
174
175To change a principal's password use the :ref:`kadmin(1)`
176**change_password** command.
177
178.. include:: admin_commands/kadmin_local.rst
179   :start-after:  _change_password:
180   :end-before: _change_password_end:
181
182.. note::
183
184          Password changes through kadmin are subject to the same
185          password policies as would apply to password changes through
186          :ref:`kpasswd(1)`.
187
188
189.. _policies:
190
191Policies
192--------
193
194A policy is a set of rules governing passwords.  Policies can dictate
195minimum and maximum password lifetimes, minimum number of characters
196and character classes a password must contain, and the number of old
197passwords kept in the database.
198
199
200Adding, modifying and deleting policies
201~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202
203To add a new policy, use the :ref:`kadmin(1)` **add_policy** command.
204
205To modify attributes of a principal, use the kadmin **modify_policy**
206command.
207
208To delete a policy, use the kadmin **delete_policy** command.
209
210.. include:: admin_commands/kadmin_local.rst
211   :start-after:  _add_policy:
212   :end-before: _add_policy_end:
213
214.. include:: admin_commands/kadmin_local.rst
215   :start-after:  _modify_policy:
216   :end-before: _modify_policy_end:
217
218.. include:: admin_commands/kadmin_local.rst
219   :start-after:  _delete_policy:
220   :end-before: _delete_policy_end:
221
222.. note::
223
224          You must cancel the policy from *all* principals before
225          deleting it.  The *delete_policy* command will fail if the policy
226          is in use by any principals.
227
228
229Retrieving policies
230~~~~~~~~~~~~~~~~~~~
231
232To retrieve a policy, use the :ref:`kadmin(1)` **get_policy** command.
233
234You can retrieve the list of policies with the kadmin
235**list_policies** command.
236
237.. include:: admin_commands/kadmin_local.rst
238   :start-after:  _get_policy:
239   :end-before: _get_policy_end:
240
241.. include:: admin_commands/kadmin_local.rst
242   :start-after:  _list_policies:
243   :end-before: _list_policies_end:
244
245
246Policies and principals
247~~~~~~~~~~~~~~~~~~~~~~~
248
249Policies can be applied to principals as they are created by using
250the **-policy** flag to :ref:`add_principal`. Existing principals can
251be modified by using the **-policy** or **-clearpolicy** flag to
252:ref:`modify_principal`.
253
254
255.. _updating_history_key:
256
257Updating the history key
258~~~~~~~~~~~~~~~~~~~~~~~~
259
260If a policy specifies a number of old keys kept of two or more, the
261stored old keys are encrypted in a history key, which is found in the
262key data of the ``kadmin/history`` principal.
263
264Currently there is no support for proper rollover of the history key,
265but you can change the history key (for example, to use a better
266encryption type) at the cost of invalidating currently stored old
267keys.  To change the history key, run::
268
269    kadmin: change_password -randkey kadmin/history
270
271This command will fail if you specify the **-keepold** flag.  Only one
272new history key will be created, even if you specify multiple key/salt
273combinations.
274
275In the future, we plan to migrate towards encrypting old keys in the
276master key instead of the history key, and implementing proper
277rollover support for stored old keys.
278
279
280.. _privileges:
281
282Privileges
283----------
284
285Administrative privileges for the Kerberos database are stored in the
286file :ref:`kadm5.acl(5)`.
287
288.. note::
289
290          A common use of an admin instance is so you can grant
291          separate permissions (such as administrator access to the
292          Kerberos database) to a separate Kerberos principal. For
293          example, the user ``joeadmin`` might have a principal for
294          his administrative use, called ``joeadmin/admin``.  This
295          way, ``joeadmin`` would obtain ``joeadmin/admin`` tickets
296          only when he actually needs to use those permissions.
297
298
299.. _db_operations:
300
301Operations on the Kerberos database
302-----------------------------------
303
304The :ref:`kdb5_util(8)` command is the primary tool for administrating
305the Kerberos database.
306
307.. include:: admin_commands/kdb5_util.rst
308   :start-after:  _kdb5_util_synopsis:
309   :end-before: _kdb5_util_synopsis_end:
310
311**OPTIONS**
312
313.. include:: admin_commands/kdb5_util.rst
314   :start-after:  _kdb5_util_options:
315   :end-before: _kdb5_util_options_end:
316
317.. toctree::
318   :maxdepth: 1
319
320
321Dumping a Kerberos database to a file
322~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
323
324To dump a Kerberos database into a file, use the :ref:`kdb5_util(8)`
325**dump** command on one of the KDCs.
326
327.. include:: admin_commands/kdb5_util.rst
328   :start-after:  _kdb5_util_dump:
329   :end-before: _kdb5_util_dump_end:
330
331
332Examples
333########
334
335::
336
337    shell% kdb5_util dump dumpfile
338    shell%
339
340    shell% kbd5_util dump -verbose dumpfile
341    kadmin/admin@ATHENA.MIT.EDU
342    krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
343    kadmin/history@ATHENA.MIT.EDU
344    K/M@ATHENA.MIT.EDU
345    kadmin/changepw@ATHENA.MIT.EDU
346    shell%
347
348If you specify which principals to dump, you must use the full
349principal, as in the following example::
350
351    shell% kdb5_util dump -verbose dumpfile K/M@ATHENA.MIT.EDU kadmin/admin@ATHENA.MIT.EDU
352    kadmin/admin@ATHENA.MIT.EDU
353    K/M@ATHENA.MIT.EDU
354    shell%
355
356Otherwise, the principals will not match those in the database and
357will not be dumped::
358
359     shell% kdb5_util dump -verbose dumpfile K/M kadmin/admin
360     shell%
361
362If you do not specify a dump file, kdb5_util will dump the database to
363the standard output.
364
365
366.. _restore_from_dump:
367
368Restoring a Kerberos database from a dump file
369~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370
371To restore a Kerberos database dump from a file, use the
372:ref:`kdb5_util(8)` **load** command on one of the KDCs.
373
374.. include:: admin_commands/kdb5_util.rst
375   :start-after:  _kdb5_util_load:
376   :end-before: _kdb5_util_load_end:
377
378
379Examples
380########
381
382To dump a single principal and later load it, updating the database:
383
384::
385
386     shell% kdb5_util dump dumpfile principal@REALM
387     shell%
388
389     shell% kdb5_util load -update dumpfile
390     shell%
391
392
393.. note::
394
395          If the database file exists, and the *-update* flag was not
396          given, *kdb5_util* will overwrite the existing database.
397
398.. note::
399
400          Using kdb5_util to dump and reload the principal database is
401          only necessary when upgrading from versions of krb5 prior
402          to 1.2.0---newer versions will use the existing database as-is.
403
404
405.. _create_stash:
406
407Creating a stash file
408~~~~~~~~~~~~~~~~~~~~~
409
410A stash file allows a KDC to authenticate itself to the database
411utilities, such as :ref:`kadmind(8)`, :ref:`krb5kdc(8)`, and
412:ref:`kdb5_util(8)`.
413
414To create a stash file, use the :ref:`kdb5_util(8)` **stash** command.
415
416.. include:: admin_commands/kdb5_util.rst
417   :start-after: _kdb5_util_stash:
418   :end-before: _kdb5_util_stash_end:
419
420
421Example
422#######
423
424    shell% kdb5_util stash
425    kdb5_util: Cannot find/read stored master key while reading master key
426    kdb5_util: Warning: proceeding without master key
427    Enter KDC database master key:  <= Type the KDC database master password.
428    shell%
429
430If you do not specify a stash file, kdb5_util will stash the key in
431the file specified in your :ref:`kdc.conf(5)` file.
432
433
434Creating and destroying a Kerberos database
435~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436
437If you need to create a new Kerberos database, use the
438:ref:`kdb5_util(8)` **create** command.
439
440.. include:: admin_commands/kdb5_util.rst
441   :start-after: _kdb5_util_create:
442   :end-before: _kdb5_util_create_end:
443
444If you need to destroy the current Kerberos database, use the
445:ref:`kdb5_util(8)` **destroy** command.
446
447.. include:: admin_commands/kdb5_util.rst
448   :start-after: _kdb5_util_destroy:
449   :end-before: _kdb5_util_destroy_end:
450
451
452Examples
453########
454
455::
456
457    shell% kdb5_util -r ATHENA.MIT.EDU create -s
458    Loading random data
459    Initializing database '/usr/local/var/krb5kdc/principal' for realm 'ATHENA.MIT.EDU',
460    master key name 'K/M@ATHENA.MIT.EDU'
461    You will be prompted for the database Master Password.
462    It is important that you NOT FORGET this password.
463    Enter KDC database master key:  <= Type the master password.
464    Re-enter KDC database master key to verify:  <= Type it again.
465    shell%
466
467    shell% kdb5_util -r ATHENA.MIT.EDU destroy
468    Deleting KDC database stored in '/usr/local/var/krb5kdc/principal', are you sure?
469    (type 'yes' to confirm)?  <= yes
470    OK, deleting database '/usr/local/var/krb5kdc/principal'...
471    ** Database '/usr/local/var/krb5kdc/principal' destroyed.
472    shell%
473
474
475.. _updating_master_key:
476
477Updating the master key
478~~~~~~~~~~~~~~~~~~~~~~~
479
480Starting with release 1.7, :ref:`kdb5_util(8)` allows the master key
481to be changed using a rollover process, with minimal loss of
482availability.  To roll over the master key, follow these steps:
483
484#. On the primary KDC, run ``kdb5_util list_mkeys`` to view the
485   current master key version number (KVNO).  If you have never rolled
486   over the master key before, this will likely be version 1::
487
488    $ kdb5_util list_mkeys
489    Master keys for Principal: K/M@KRBTEST.COM
490    KVNO: 1, Enctype: aes256-cts-hmac-sha384-192, Active on: Thu Jan 01 00:00:00 UTC 1970 *
491
492#. On the primary KDC, run ``kdb5_util use_mkey 1`` to ensure that a
493   master key activation list is present in the database.  This step
494   is unnecessary in release 1.11.4 or later, or if the database was
495   initially created with release 1.7 or later.
496
497#. On the primary KDC, run ``kdb5_util add_mkey -s`` to create a new
498   master key and write it to the stash file.  Enter a secure password
499   when prompted.  If this is the first time you are changing the
500   master key, the new key will have version 2.  The new master key
501   will not be used until you make it active.
502
503#. Propagate the database to all replica KDCs, either manually or by
504   waiting until the next scheduled propagation.  If you do not have
505   any replica KDCs, you can skip this and the next step.
506
507#. On each replica KDC, run ``kdb5_util list_mkeys`` to verify that
508   the new master key is present, and then ``kdb5_util stash`` to
509   write the new master key to the replica KDC's stash file.
510
511#. On the primary KDC, run ``kdb5_util use_mkey 2`` to begin using the
512   new master key.  Replace ``2`` with the version of the new master
513   key, as appropriate.  You can optionally specify a date for the new
514   master key to become active; by default, it will become active
515   immediately.  Prior to release 1.12, :ref:`kadmind(8)` must be
516   restarted for this change to take full effect.
517
518#. On the primary KDC, run ``kdb5_util update_princ_encryption``.
519   This command will iterate over the database and re-encrypt all keys
520   in the new master key.  If the database is large and uses DB2, the
521   primary KDC will become unavailable while this command runs, but
522   clients should fail over to replica KDCs (if any are present)
523   during this time period.  In release 1.13 and later, you can
524   instead run ``kdb5_util -x unlockiter update_princ_encryption`` to
525   use unlocked iteration; this variant will take longer, but will
526   keep the database available to the KDC and kadmind while it runs.
527
528#. Wait until the above changes have propagated to all replica KDCs
529   and until all running KDC and kadmind processes have serviced
530   requests using updated principal entries.
531
532#. On the primary KDC, run ``kdb5_util purge_mkeys`` to clean up the
533   old master key.
534
535
536.. _ops_on_ldap:
537
538Operations on the LDAP database
539-------------------------------
540
541The :ref:`kdb5_ldap_util(8)` is the primary tool for administrating
542the Kerberos LDAP database.  It allows an administrator to manage
543realms, Kerberos services (KDC and Admin Server) and ticket policies.
544
545.. include:: admin_commands/kdb5_ldap_util.rst
546   :start-after:  _kdb5_ldap_util_synopsis:
547   :end-before: _kdb5_ldap_util_synopsis_end:
548
549**OPTIONS**
550
551.. include:: admin_commands/kdb5_ldap_util.rst
552   :start-after:  _kdb5_ldap_util_options:
553   :end-before: _kdb5_ldap_util_options_end:
554
555
556.. _ldap_create_realm:
557
558Creating a Kerberos realm
559~~~~~~~~~~~~~~~~~~~~~~~~~
560
561If you need to create a new realm, use the :ref:`kdb5_ldap_util(8)`
562**create** command as follows.
563
564.. include:: admin_commands/kdb5_ldap_util.rst
565   :start-after:  _kdb5_ldap_util_create:
566   :end-before: _kdb5_ldap_util_create_end:
567
568
569.. _ldap_mod_realm:
570
571Modifying a Kerberos realm
572~~~~~~~~~~~~~~~~~~~~~~~~~~
573
574If you need to modify a realm, use the :ref:`kdb5_ldap_util(8)`
575**modify** command as follows.
576
577.. include:: admin_commands/kdb5_ldap_util.rst
578   :start-after:  _kdb5_ldap_util_modify:
579   :end-before: _kdb5_ldap_util_modify_end:
580
581
582Destroying a Kerberos realm
583~~~~~~~~~~~~~~~~~~~~~~~~~~~
584
585If you need to destroy a Kerberos realm, use the
586:ref:`kdb5_ldap_util(8)` **destroy** command as follows.
587
588.. include:: admin_commands/kdb5_ldap_util.rst
589   :start-after:  _kdb5_ldap_util_destroy:
590   :end-before: _kdb5_ldap_util_destroy_end:
591
592
593Retrieving information about a Kerberos realm
594~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
595
596If you need to display the attributes of a realm, use the
597:ref:`kdb5_ldap_util(8)` **view** command as follows.
598
599.. include:: admin_commands/kdb5_ldap_util.rst
600   :start-after:  _kdb5_ldap_util_view:
601   :end-before: _kdb5_ldap_util_view_end:
602
603
604Listing available Kerberos realms
605~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
606
607If you need to display the list of the realms, use the
608:ref:`kdb5_ldap_util(8)` **list** command as follows.
609
610.. include:: admin_commands/kdb5_ldap_util.rst
611   :start-after:  _kdb5_ldap_util_list:
612   :end-before: _kdb5_ldap_util_list_end:
613
614
615.. _stash_ldap:
616
617Stashing service object's password
618~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
619
620The :ref:`kdb5_ldap_util(8)` **stashsrvpw** command allows an
621administrator to store the password of service object in a file.  The
622KDC and Administration server uses this password to authenticate to
623the LDAP server.
624
625.. include:: admin_commands/kdb5_ldap_util.rst
626   :start-after:  _kdb5_ldap_util_stashsrvpw:
627   :end-before: _kdb5_ldap_util_stashsrvpw_end:
628
629
630Ticket Policy operations
631~~~~~~~~~~~~~~~~~~~~~~~~
632
633Creating a Ticket Policy
634########################
635
636To create a new ticket policy in directory , use the
637:ref:`kdb5_ldap_util(8)` **create_policy** command.  Ticket policy
638objects are created under the realm container.
639
640.. include:: admin_commands/kdb5_ldap_util.rst
641   :start-after:  _kdb5_ldap_util_create_policy:
642   :end-before: _kdb5_ldap_util_create_policy_end:
643
644
645Modifying a Ticket Policy
646#########################
647
648To modify a ticket policy in directory, use the
649:ref:`kdb5_ldap_util(8)` **modify_policy** command.
650
651.. include:: admin_commands/kdb5_ldap_util.rst
652   :start-after:  _kdb5_ldap_util_modify_policy:
653   :end-before: _kdb5_ldap_util_modify_policy_end:
654
655
656Retrieving Information About a Ticket Policy
657############################################
658
659To display the attributes of a ticket policy, use the
660:ref:`kdb5_ldap_util(8)` **view_policy** command.
661
662.. include:: admin_commands/kdb5_ldap_util.rst
663   :start-after:  _kdb5_ldap_util_view_policy:
664   :end-before: _kdb5_ldap_util_view_policy_end:
665
666
667Destroying a Ticket Policy
668##########################
669
670To destroy an existing ticket policy, use the :ref:`kdb5_ldap_util(8)`
671**destroy_policy** command.
672
673.. include:: admin_commands/kdb5_ldap_util.rst
674   :start-after:  _kdb5_ldap_util_destroy_policy:
675   :end-before: _kdb5_ldap_util_destroy_policy_end:
676
677
678Listing available Ticket Policies
679#################################
680
681To list the name of ticket policies in a realm, use the
682:ref:`kdb5_ldap_util(8)` **list_policy** command.
683
684.. include:: admin_commands/kdb5_ldap_util.rst
685   :start-after:  _kdb5_ldap_util_list_policy:
686   :end-before: _kdb5_ldap_util_list_policy_end:
687
688
689.. _xrealm_authn:
690
691Cross-realm authentication
692--------------------------
693
694In order for a KDC in one realm to authenticate Kerberos users in a
695different realm, it must share a key with the KDC in the other realm.
696In both databases, there must be krbtgt service principals for both realms.
697For example, if you need to do cross-realm authentication between the realms
698``ATHENA.MIT.EDU`` and ``EXAMPLE.COM``, you would need to add the
699principals ``krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU`` and
700``krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM`` to both databases.
701These principals must all have the same passwords, key version
702numbers, and encryption types; this may require explicitly setting
703the key version number with the **-kvno** option.
704
705In the ATHENA.MIT.EDU and EXAMPLE.COM cross-realm case, the administrators
706would run the following commands on the KDCs in both realms::
707
708    shell%: kadmin.local -e "aes256-cts:normal"
709    kadmin: addprinc -requires_preauth krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM
710    Enter password for principal krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM:
711    Re-enter password for principal krbtgt/ATHENA.MIT.EDU@EXAMPLE.COM:
712    kadmin: addprinc -requires_preauth krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU
713    Enter password for principal krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU:
714    Enter password for principal krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU:
715    kadmin:
716
717.. note::
718
719          Even if most principals in a realm are generally created
720          with the **requires_preauth** flag enabled, this flag is not
721          desirable on cross-realm authentication keys because doing
722          so makes it impossible to disable preauthentication on a
723          service-by-service basis.  Disabling it as in the example
724          above is recommended.
725
726.. note::
727
728          It is very important that these principals have good
729          passwords.  MIT recommends that TGT principal passwords be
730          at least 26 characters of random ASCII text.
731
732
733.. _changing_krbtgt_key:
734
735Changing the krbtgt key
736-----------------------
737
738A Kerberos Ticket Granting Ticket (TGT) is a service ticket for the
739principal ``krbtgt/REALM``.  The key for this principal is created
740when the Kerberos database is initialized and need not be changed.
741However, it will only have the encryption types supported by the KDC
742at the time of the initial database creation.  To allow use of newer
743encryption types for the TGT, this key has to be changed.
744
745Changing this key using the normal :ref:`kadmin(1)`
746**change_password** command would invalidate any previously issued
747TGTs.  Therefore, when changing this key, normally one should use the
748**-keepold** flag to change_password to retain the previous key in the
749database as well as the new key.  For example::
750
751    kadmin: change_password -randkey -keepold krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
752
753.. warning::
754
755             After issuing this command, the old key is still valid
756             and is still vulnerable to (for instance) brute force
757             attacks.  To completely retire an old key or encryption
758             type, run the kadmin **purgekeys** command to delete keys
759             with older kvnos, ideally first making sure that all
760             tickets issued with the old keys have expired.
761
762Only the first krbtgt key of the newest key version is used to encrypt
763ticket-granting tickets.  However, the set of encryption types present
764in the krbtgt keys is used by default to determine the session key
765types supported by the krbtgt service (see
766:ref:`session_key_selection`).  Because non-MIT Kerberos clients
767sometimes send a limited set of encryption types when making AS
768requests, it can be important for the krbtgt service to support
769multiple encryption types.  This can be accomplished by giving the
770krbtgt principal multiple keys, which is usually as simple as not
771specifying any **-e** option when changing the krbtgt key, or by
772setting the **session_enctypes** string attribute on the krbtgt
773principal (see :ref:`set_string`).
774
775Due to a bug in releases 1.8 through 1.13, renewed and forwarded
776tickets may not work if the original ticket was obtained prior to a
777krbtgt key change and the modified ticket is obtained afterwards.
778Upgrading the KDC to release 1.14 or later will correct this bug.
779
780
781.. _incr_db_prop:
782
783Incremental database propagation
784--------------------------------
785
786Overview
787~~~~~~~~
788
789At some very large sites, dumping and transmitting the database can
790take more time than is desirable for changes to propagate from the
791primary KDC to the replica KDCs.  The incremental propagation support
792added in the 1.7 release is intended to address this.
793
794With incremental propagation enabled, all programs on the primary KDC
795that change the database also write information about the changes to
796an "update log" file, maintained as a circular buffer of a certain
797size.  A process on each replica KDC connects to a service on the
798primary KDC (currently implemented in the :ref:`kadmind(8)` server) and
799periodically requests the changes that have been made since the last
800check.  By default, this check is done every two minutes.
801
802Incremental propagation uses the following entries in the per-realm
803data in the KDC config file (See :ref:`kdc.conf(5)`):
804
805====================== =============== ===========================================
806iprop_enable           *boolean*       If *true*, then incremental propagation is enabled, and (as noted below) normal kprop propagation is disabled. The default is *false*.
807iprop_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.
808iprop_replica_poll     *time interval* Indicates how often the replica should poll the primary KDC for changes to the database. The default is two minutes.
809iprop_port             *integer*       Specifies the port number to be used for incremental propagation. This is required in both primary and replica configuration files.
810iprop_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).
811iprop_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.)
812====================== =============== ===========================================
813
814Both primary and replica sides must have a principal named
815``kiprop/hostname`` (where *hostname* is the lowercase,
816fully-qualified, canonical name for the host) registered in the
817Kerberos database, and have keys for that principal stored in the
818default keytab file (|keytab|).  The ``kiprop/hostname`` principal may
819have been created automatically for the primary KDC, but it must
820always be created for replica KDCs.
821
822On the primary KDC side, the ``kiprop/hostname`` principal must be
823listed in the kadmind ACL file :ref:`kadm5.acl(5)`, and given the
824**p** privilege (see :ref:`privileges`).
825
826On the replica KDC side, :ref:`kpropd(8)` should be run.  When
827incremental propagation is enabled, it will connect to the kadmind on
828the primary KDC and start requesting updates.
829
830The normal kprop mechanism is disabled by the incremental propagation
831support.  However, if the replica has been unable to fetch changes
832from the primary KDC for too long (network problems, perhaps), the log
833on the primary may wrap around and overwrite some of the updates that
834the replica has not yet retrieved.  In this case, the replica will
835instruct the primary KDC to dump the current database out to a file
836and invoke a one-time kprop propagation, with special options to also
837convey the point in the update log at which the replica should resume
838fetching incremental updates.  Thus, all the keytab and ACL setup
839previously described for kprop propagation is still needed.
840
841If an environment has a large number of replicas, it may be desirable
842to arrange them in a hierarchy instead of having the primary serve
843updates to every replica.  To do this, run ``kadmind -proponly`` on
844each intermediate replica, and ``kpropd -A upstreamhostname`` on
845downstream replicas to direct each one to the appropriate upstream
846replica.
847
848There are several known restrictions in the current implementation:
849
850- The incremental update protocol does not transport changes to policy
851  objects.  Any policy changes on the primary will result in full
852  resyncs to all replicas.
853- The replica's KDB module must support locking; it cannot be using the
854  LDAP KDB module.
855- The primary and replica must be able to initiate TCP connections in
856  both directions, without an intervening NAT.
857
858
859Sun/MIT incremental propagation differences
860~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
861
862Sun donated the original code for supporting incremental database
863propagation to MIT.  Some changes have been made in the MIT source
864tree that will be visible to administrators.  (These notes are based
865on Sun's patches.  Changes to Sun's implementation since then may not
866be reflected here.)
867
868The Sun config file support looks for ``sunw_dbprop_enable``,
869``sunw_dbprop_master_ulogsize``, and ``sunw_dbprop_slave_poll``.
870
871The incremental propagation service is implemented as an ONC RPC
872service.  In the Sun implementation, the service is registered with
873rpcbind (also known as portmapper) and the client looks up the port
874number to contact.  In the MIT implementation, where interaction with
875some modern versions of rpcbind doesn't always work well, the port
876number must be specified in the config file on both the primary and
877replica sides.
878
879The Sun implementation hard-codes pathnames in ``/var/krb5`` for the
880update log and the per-replica kprop dump files.  In the MIT
881implementation, the pathname for the update log is specified in the
882config file, and the per-replica dump files are stored in
883|kdcdir|\ ``/replica_datatrans_hostname``.
884