xref: /freebsd/crypto/krb5/doc/admin/install_kdc.rst (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy SchubertInstalling KDCs
2*7f2fe78bSCy Schubert===============
3*7f2fe78bSCy Schubert
4*7f2fe78bSCy SchubertWhen setting up Kerberos in a production environment, it is best to
5*7f2fe78bSCy Schuberthave multiple replica KDCs alongside with a primary KDC to ensure the
6*7f2fe78bSCy Schubertcontinued availability of the Kerberized services.  Each KDC contains
7*7f2fe78bSCy Schuberta copy of the Kerberos database.  The primary KDC contains the
8*7f2fe78bSCy Schubertwritable copy of the realm database, which it replicates to the
9*7f2fe78bSCy Schubertreplica KDCs at regular intervals.  All database changes (such as
10*7f2fe78bSCy Schubertpassword changes) are made on the primary KDC.  Replica KDCs provide
11*7f2fe78bSCy SchubertKerberos ticket-granting services, but not database administration,
12*7f2fe78bSCy Schubertwhen the primary KDC is unavailable.  MIT recommends that you install
13*7f2fe78bSCy Schubertall of your KDCs to be able to function as either the primary or one
14*7f2fe78bSCy Schubertof the replicas.  This will enable you to easily switch your primary
15*7f2fe78bSCy SchubertKDC with one of the replicas if necessary (see
16*7f2fe78bSCy Schubert:ref:`switch_primary_replica`).  This installation procedure is based
17*7f2fe78bSCy Schuberton that recommendation.
18*7f2fe78bSCy Schubert
19*7f2fe78bSCy Schubert.. warning::
20*7f2fe78bSCy Schubert
21*7f2fe78bSCy Schubert    - The Kerberos system relies on the availability of correct time
22*7f2fe78bSCy Schubert      information.  Ensure that the primary and all replica KDCs have
23*7f2fe78bSCy Schubert      properly synchronized clocks.
24*7f2fe78bSCy Schubert
25*7f2fe78bSCy Schubert    - It is best to install and run KDCs on secured and dedicated
26*7f2fe78bSCy Schubert      hardware with limited access.  If your KDC is also a file
27*7f2fe78bSCy Schubert      server, FTP server, Web server, or even just a client machine,
28*7f2fe78bSCy Schubert      someone who obtained root access through a security hole in any
29*7f2fe78bSCy Schubert      of those areas could potentially gain access to the Kerberos
30*7f2fe78bSCy Schubert      database.
31*7f2fe78bSCy Schubert
32*7f2fe78bSCy Schubert
33*7f2fe78bSCy SchubertInstall and configure the primary KDC
34*7f2fe78bSCy Schubert-------------------------------------
35*7f2fe78bSCy Schubert
36*7f2fe78bSCy SchubertInstall Kerberos either from the OS-provided packages or from the
37*7f2fe78bSCy Schubertsource (See :ref:`do_build`).
38*7f2fe78bSCy Schubert
39*7f2fe78bSCy Schubert.. note::
40*7f2fe78bSCy Schubert
41*7f2fe78bSCy Schubert          For the purpose of this document we will use the following
42*7f2fe78bSCy Schubert          names::
43*7f2fe78bSCy Schubert
44*7f2fe78bSCy Schubert             kerberos.mit.edu    - primary KDC
45*7f2fe78bSCy Schubert             kerberos-1.mit.edu  - replica KDC
46*7f2fe78bSCy Schubert             ATHENA.MIT.EDU      - realm name
47*7f2fe78bSCy Schubert             .k5.ATHENA.MIT.EDU  - stash file
48*7f2fe78bSCy Schubert             admin/admin         - admin principal
49*7f2fe78bSCy Schubert
50*7f2fe78bSCy Schubert          See :ref:`mitK5defaults` for the default names and locations
51*7f2fe78bSCy Schubert          of the relevant to this topic files.  Adjust the names and
52*7f2fe78bSCy Schubert          paths to your system environment.
53*7f2fe78bSCy Schubert
54*7f2fe78bSCy Schubert
55*7f2fe78bSCy SchubertEdit KDC configuration files
56*7f2fe78bSCy Schubert----------------------------
57*7f2fe78bSCy Schubert
58*7f2fe78bSCy SchubertModify the configuration files, :ref:`krb5.conf(5)` and
59*7f2fe78bSCy Schubert:ref:`kdc.conf(5)`, to reflect the correct information (such as
60*7f2fe78bSCy Schubertdomain-realm mappings and Kerberos servers names) for your realm.
61*7f2fe78bSCy Schubert(See :ref:`mitK5defaults` for the recommended default locations for
62*7f2fe78bSCy Schubertthese files).
63*7f2fe78bSCy Schubert
64*7f2fe78bSCy SchubertMost of the tags in the configuration have default values that will
65*7f2fe78bSCy Schubertwork well for most sites.  There are some tags in the
66*7f2fe78bSCy Schubert:ref:`krb5.conf(5)` file whose values must be specified, and this
67*7f2fe78bSCy Schubertsection will explain those.
68*7f2fe78bSCy Schubert
69*7f2fe78bSCy SchubertIf the locations for these configuration files differs from the
70*7f2fe78bSCy Schubertdefault ones, set **KRB5_CONFIG** and **KRB5_KDC_PROFILE** environment
71*7f2fe78bSCy Schubertvariables to point to the krb5.conf and kdc.conf respectively.  For
72*7f2fe78bSCy Schubertexample::
73*7f2fe78bSCy Schubert
74*7f2fe78bSCy Schubert    export KRB5_CONFIG=/yourdir/krb5.conf
75*7f2fe78bSCy Schubert    export KRB5_KDC_PROFILE=/yourdir/kdc.conf
76*7f2fe78bSCy Schubert
77*7f2fe78bSCy Schubert
78*7f2fe78bSCy Schubertkrb5.conf
79*7f2fe78bSCy Schubert~~~~~~~~~
80*7f2fe78bSCy Schubert
81*7f2fe78bSCy SchubertIf you are not using DNS TXT records (see :ref:`mapping_hostnames`),
82*7f2fe78bSCy Schubertyou must specify the **default_realm** in the :ref:`libdefaults`
83*7f2fe78bSCy Schubertsection.  If you are not using DNS URI or SRV records (see
84*7f2fe78bSCy Schubert:ref:`kdc_hostnames` and :ref:`kdc_discovery`), you must include the
85*7f2fe78bSCy Schubert**kdc** tag for each *realm* in the :ref:`realms` section.  To
86*7f2fe78bSCy Schubertcommunicate with the kadmin server in each realm, the **admin_server**
87*7f2fe78bSCy Schuberttag must be set in the
88*7f2fe78bSCy Schubert:ref:`realms` section.
89*7f2fe78bSCy Schubert
90*7f2fe78bSCy SchubertAn example krb5.conf file::
91*7f2fe78bSCy Schubert
92*7f2fe78bSCy Schubert    [libdefaults]
93*7f2fe78bSCy Schubert        default_realm = ATHENA.MIT.EDU
94*7f2fe78bSCy Schubert
95*7f2fe78bSCy Schubert    [realms]
96*7f2fe78bSCy Schubert        ATHENA.MIT.EDU = {
97*7f2fe78bSCy Schubert            kdc = kerberos.mit.edu
98*7f2fe78bSCy Schubert            kdc = kerberos-1.mit.edu
99*7f2fe78bSCy Schubert            admin_server = kerberos.mit.edu
100*7f2fe78bSCy Schubert        }
101*7f2fe78bSCy Schubert
102*7f2fe78bSCy Schubert
103*7f2fe78bSCy Schubertkdc.conf
104*7f2fe78bSCy Schubert~~~~~~~~
105*7f2fe78bSCy Schubert
106*7f2fe78bSCy SchubertThe kdc.conf file can be used to control the listening ports of the
107*7f2fe78bSCy SchubertKDC and kadmind, as well as realm-specific defaults, the database type
108*7f2fe78bSCy Schubertand location, and logging.
109*7f2fe78bSCy Schubert
110*7f2fe78bSCy SchubertAn example kdc.conf file::
111*7f2fe78bSCy Schubert
112*7f2fe78bSCy Schubert    [kdcdefaults]
113*7f2fe78bSCy Schubert        kdc_listen = 88
114*7f2fe78bSCy Schubert        kdc_tcp_listen = 88
115*7f2fe78bSCy Schubert
116*7f2fe78bSCy Schubert    [realms]
117*7f2fe78bSCy Schubert        ATHENA.MIT.EDU = {
118*7f2fe78bSCy Schubert            kadmind_port = 749
119*7f2fe78bSCy Schubert            max_life = 12h 0m 0s
120*7f2fe78bSCy Schubert            max_renewable_life = 7d 0h 0m 0s
121*7f2fe78bSCy Schubert            master_key_type = aes256-cts
122*7f2fe78bSCy Schubert            supported_enctypes = aes256-cts:normal aes128-cts:normal
123*7f2fe78bSCy Schubert            # If the default location does not suit your setup,
124*7f2fe78bSCy Schubert            # explicitly configure the following values:
125*7f2fe78bSCy Schubert            #    database_name = /var/krb5kdc/principal
126*7f2fe78bSCy Schubert            #    key_stash_file = /var/krb5kdc/.k5.ATHENA.MIT.EDU
127*7f2fe78bSCy Schubert            #    acl_file = /var/krb5kdc/kadm5.acl
128*7f2fe78bSCy Schubert        }
129*7f2fe78bSCy Schubert
130*7f2fe78bSCy Schubert    [logging]
131*7f2fe78bSCy Schubert        # By default, the KDC and kadmind will log output using
132*7f2fe78bSCy Schubert        # syslog.  You can instead send log output to files like this:
133*7f2fe78bSCy Schubert        kdc = FILE:/var/log/krb5kdc.log
134*7f2fe78bSCy Schubert        admin_server = FILE:/var/log/kadmin.log
135*7f2fe78bSCy Schubert        default = FILE:/var/log/krb5lib.log
136*7f2fe78bSCy Schubert
137*7f2fe78bSCy SchubertReplace ``ATHENA.MIT.EDU`` and ``kerberos.mit.edu`` with the name of
138*7f2fe78bSCy Schubertyour Kerberos realm and server respectively.
139*7f2fe78bSCy Schubert
140*7f2fe78bSCy Schubert.. note::
141*7f2fe78bSCy Schubert
142*7f2fe78bSCy Schubert          You have to have write permission on the target directories
143*7f2fe78bSCy Schubert          (these directories must exist) used by **database_name**,
144*7f2fe78bSCy Schubert          **key_stash_file**, and **acl_file**.
145*7f2fe78bSCy Schubert
146*7f2fe78bSCy Schubert
147*7f2fe78bSCy Schubert.. _create_db:
148*7f2fe78bSCy Schubert
149*7f2fe78bSCy SchubertCreate the KDC database
150*7f2fe78bSCy Schubert-----------------------
151*7f2fe78bSCy Schubert
152*7f2fe78bSCy SchubertYou will use the :ref:`kdb5_util(8)` command on the primary KDC to
153*7f2fe78bSCy Schubertcreate the Kerberos database and the optional :ref:`stash_definition`.
154*7f2fe78bSCy Schubert
155*7f2fe78bSCy Schubert.. note::
156*7f2fe78bSCy Schubert
157*7f2fe78bSCy Schubert          If you choose not to install a stash file, the KDC will
158*7f2fe78bSCy Schubert          prompt you for the master key each time it starts up.  This
159*7f2fe78bSCy Schubert          means that the KDC will not be able to start automatically,
160*7f2fe78bSCy Schubert          such as after a system reboot.
161*7f2fe78bSCy Schubert
162*7f2fe78bSCy Schubert:ref:`kdb5_util(8)` will prompt you for the master password for the
163*7f2fe78bSCy SchubertKerberos database.  This password can be any string.  A good password
164*7f2fe78bSCy Schubertis one you can remember, but that no one else can guess.  Examples of
165*7f2fe78bSCy Schubertbad passwords are words that can be found in a dictionary, any common
166*7f2fe78bSCy Schubertor popular name, especially a famous person (or cartoon character),
167*7f2fe78bSCy Schubertyour username in any form (e.g., forward, backward, repeated twice,
168*7f2fe78bSCy Schubertetc.), and any of the sample passwords that appear in this manual.
169*7f2fe78bSCy SchubertOne example of a password which might be good if it did not appear in
170*7f2fe78bSCy Schubertthis manual is "MITiys4K5!", which represents the sentence "MIT is
171*7f2fe78bSCy Schubertyour source for Kerberos 5!"  (It's the first letter of each word,
172*7f2fe78bSCy Schubertsubstituting the numeral "4" for the word "for", and includes the
173*7f2fe78bSCy Schubertpunctuation mark at the end.)
174*7f2fe78bSCy Schubert
175*7f2fe78bSCy SchubertThe following is an example of how to create a Kerberos database and
176*7f2fe78bSCy Schubertstash file on the primary KDC, using the :ref:`kdb5_util(8)` command.
177*7f2fe78bSCy SchubertReplace ``ATHENA.MIT.EDU`` with the name of your Kerberos realm::
178*7f2fe78bSCy Schubert
179*7f2fe78bSCy Schubert    shell% kdb5_util create -r ATHENA.MIT.EDU -s
180*7f2fe78bSCy Schubert
181*7f2fe78bSCy Schubert    Initializing database '/usr/local/var/krb5kdc/principal' for realm 'ATHENA.MIT.EDU',
182*7f2fe78bSCy Schubert    master key name 'K/M@ATHENA.MIT.EDU'
183*7f2fe78bSCy Schubert    You will be prompted for the database Master Password.
184*7f2fe78bSCy Schubert    It is important that you NOT FORGET this password.
185*7f2fe78bSCy Schubert    Enter KDC database master key:  <= Type the master password.
186*7f2fe78bSCy Schubert    Re-enter KDC database master key to verify:  <= Type it again.
187*7f2fe78bSCy Schubert    shell%
188*7f2fe78bSCy Schubert
189*7f2fe78bSCy SchubertThis will create five files in |kdcdir| (or at the locations specified
190*7f2fe78bSCy Schubertin :ref:`kdc.conf(5)`):
191*7f2fe78bSCy Schubert
192*7f2fe78bSCy Schubert* two Kerberos database files, ``principal``, and ``principal.ok``
193*7f2fe78bSCy Schubert* the Kerberos administrative database file, ``principal.kadm5``
194*7f2fe78bSCy Schubert* the administrative database lock file, ``principal.kadm5.lock``
195*7f2fe78bSCy Schubert* the stash file, in this example ``.k5.ATHENA.MIT.EDU``.  If you do
196*7f2fe78bSCy Schubert  not want a stash file, run the above command without the **-s**
197*7f2fe78bSCy Schubert  option.
198*7f2fe78bSCy Schubert
199*7f2fe78bSCy SchubertFor more information on administrating Kerberos database see
200*7f2fe78bSCy Schubert:ref:`db_operations`.
201*7f2fe78bSCy Schubert
202*7f2fe78bSCy Schubert
203*7f2fe78bSCy Schubert.. _admin_acl:
204*7f2fe78bSCy Schubert
205*7f2fe78bSCy SchubertAdd administrators to the ACL file
206*7f2fe78bSCy Schubert----------------------------------
207*7f2fe78bSCy Schubert
208*7f2fe78bSCy SchubertNext, you need create an Access Control List (ACL) file and put the
209*7f2fe78bSCy SchubertKerberos principal of at least one of the administrators into it.
210*7f2fe78bSCy SchubertThis file is used by the :ref:`kadmind(8)` daemon to control which
211*7f2fe78bSCy Schubertprincipals may view and make privileged modifications to the Kerberos
212*7f2fe78bSCy Schubertdatabase files.  The ACL filename is determined by the **acl_file**
213*7f2fe78bSCy Schubertvariable in :ref:`kdc.conf(5)`; the default is |kdcdir|\
214*7f2fe78bSCy Schubert``/kadm5.acl``.
215*7f2fe78bSCy Schubert
216*7f2fe78bSCy SchubertFor more information on Kerberos ACL file see :ref:`kadm5.acl(5)`.
217*7f2fe78bSCy Schubert
218*7f2fe78bSCy Schubert.. _addadmin_kdb:
219*7f2fe78bSCy Schubert
220*7f2fe78bSCy SchubertAdd administrators to the Kerberos database
221*7f2fe78bSCy Schubert-------------------------------------------
222*7f2fe78bSCy Schubert
223*7f2fe78bSCy SchubertNext you need to add administrative principals (i.e., principals who
224*7f2fe78bSCy Schubertare allowed to administer Kerberos database) to the Kerberos database.
225*7f2fe78bSCy SchubertYou *must* add at least one principal now to allow communication
226*7f2fe78bSCy Schubertbetween the Kerberos administration daemon kadmind and the kadmin
227*7f2fe78bSCy Schubertprogram over the network for further administration.  To do this, use
228*7f2fe78bSCy Schubertthe kadmin.local utility on the primary KDC.  kadmin.local is designed
229*7f2fe78bSCy Schubertto be run on the primary KDC host without using Kerberos
230*7f2fe78bSCy Schubertauthentication to an admin server; instead, it must have read and
231*7f2fe78bSCy Schubertwrite access to the Kerberos database on the local filesystem.
232*7f2fe78bSCy Schubert
233*7f2fe78bSCy SchubertThe administrative principals you create should be the ones you added
234*7f2fe78bSCy Schubertto the ACL file (see :ref:`admin_acl`).
235*7f2fe78bSCy Schubert
236*7f2fe78bSCy SchubertIn the following example, the administrative principal ``admin/admin``
237*7f2fe78bSCy Schubertis created::
238*7f2fe78bSCy Schubert
239*7f2fe78bSCy Schubert    shell% kadmin.local
240*7f2fe78bSCy Schubert
241*7f2fe78bSCy Schubert    kadmin.local: addprinc admin/admin@ATHENA.MIT.EDU
242*7f2fe78bSCy Schubert
243*7f2fe78bSCy Schubert    No policy specified for "admin/admin@ATHENA.MIT.EDU";
244*7f2fe78bSCy Schubert    assigning "default".
245*7f2fe78bSCy Schubert    Enter password for principal admin/admin@ATHENA.MIT.EDU:  <= Enter a password.
246*7f2fe78bSCy Schubert    Re-enter password for principal admin/admin@ATHENA.MIT.EDU:  <= Type it again.
247*7f2fe78bSCy Schubert    Principal "admin/admin@ATHENA.MIT.EDU" created.
248*7f2fe78bSCy Schubert    kadmin.local:
249*7f2fe78bSCy Schubert
250*7f2fe78bSCy Schubert.. _start_kdc_daemons:
251*7f2fe78bSCy Schubert
252*7f2fe78bSCy SchubertStart the Kerberos daemons on the primary KDC
253*7f2fe78bSCy Schubert---------------------------------------------
254*7f2fe78bSCy Schubert
255*7f2fe78bSCy SchubertAt this point, you are ready to start the Kerberos KDC
256*7f2fe78bSCy Schubert(:ref:`krb5kdc(8)`) and administrative daemons on the primary KDC.  To
257*7f2fe78bSCy Schubertdo so, type::
258*7f2fe78bSCy Schubert
259*7f2fe78bSCy Schubert    shell% krb5kdc
260*7f2fe78bSCy Schubert    shell% kadmind
261*7f2fe78bSCy Schubert
262*7f2fe78bSCy SchubertEach server daemon will fork and run in the background.
263*7f2fe78bSCy Schubert
264*7f2fe78bSCy Schubert.. note::
265*7f2fe78bSCy Schubert
266*7f2fe78bSCy Schubert          Assuming you want these daemons to start up automatically at
267*7f2fe78bSCy Schubert          boot time, you can add them to the KDC's ``/etc/rc`` or
268*7f2fe78bSCy Schubert          ``/etc/inittab`` file.  You need to have a
269*7f2fe78bSCy Schubert          :ref:`stash_definition` in order to do this.
270*7f2fe78bSCy Schubert
271*7f2fe78bSCy SchubertYou can verify that they started properly by checking for their
272*7f2fe78bSCy Schubertstartup messages in the logging locations you defined in
273*7f2fe78bSCy Schubert:ref:`krb5.conf(5)` (see :ref:`logging`).  For example::
274*7f2fe78bSCy Schubert
275*7f2fe78bSCy Schubert    shell% tail /var/log/krb5kdc.log
276*7f2fe78bSCy Schubert    Dec 02 12:35:47 beeblebrox krb5kdc[3187](info): commencing operation
277*7f2fe78bSCy Schubert    shell% tail /var/log/kadmin.log
278*7f2fe78bSCy Schubert    Dec 02 12:35:52 beeblebrox kadmind[3189](info): starting
279*7f2fe78bSCy Schubert
280*7f2fe78bSCy SchubertAny errors the daemons encounter while starting will also be listed in
281*7f2fe78bSCy Schubertthe logging output.
282*7f2fe78bSCy Schubert
283*7f2fe78bSCy SchubertAs an additional verification, check if :ref:`kinit(1)` succeeds
284*7f2fe78bSCy Schubertagainst the principals that you have created on the previous step
285*7f2fe78bSCy Schubert(:ref:`addadmin_kdb`).  Run::
286*7f2fe78bSCy Schubert
287*7f2fe78bSCy Schubert    shell% kinit admin/admin@ATHENA.MIT.EDU
288*7f2fe78bSCy Schubert
289*7f2fe78bSCy Schubert
290*7f2fe78bSCy SchubertInstall the replica KDCs
291*7f2fe78bSCy Schubert------------------------
292*7f2fe78bSCy Schubert
293*7f2fe78bSCy SchubertYou are now ready to start configuring the replica KDCs.
294*7f2fe78bSCy Schubert
295*7f2fe78bSCy Schubert.. note::
296*7f2fe78bSCy Schubert
297*7f2fe78bSCy Schubert          Assuming you are setting the KDCs up so that you can easily
298*7f2fe78bSCy Schubert          switch the primary KDC with one of the replicas, you should
299*7f2fe78bSCy Schubert          perform each of these steps on the primary KDC as well as
300*7f2fe78bSCy Schubert          the replica KDCs, unless these instructions specify
301*7f2fe78bSCy Schubert          otherwise.
302*7f2fe78bSCy Schubert
303*7f2fe78bSCy Schubert
304*7f2fe78bSCy Schubert.. _replica_host_key:
305*7f2fe78bSCy Schubert
306*7f2fe78bSCy SchubertCreate host keytabs for replica KDCs
307*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
308*7f2fe78bSCy Schubert
309*7f2fe78bSCy SchubertEach KDC needs a ``host`` key in the Kerberos database.  These keys
310*7f2fe78bSCy Schubertare used for mutual authentication when propagating the database dump
311*7f2fe78bSCy Schubertfile from the primary KDC to the secondary KDC servers.
312*7f2fe78bSCy Schubert
313*7f2fe78bSCy SchubertOn the primary KDC, connect to administrative interface and create the
314*7f2fe78bSCy Schuberthost principal for each of the KDCs' ``host`` services.  For example,
315*7f2fe78bSCy Schubertif the primary KDC were called ``kerberos.mit.edu``, and you had a
316*7f2fe78bSCy Schubertreplica KDC named ``kerberos-1.mit.edu``, you would type the
317*7f2fe78bSCy Schubertfollowing::
318*7f2fe78bSCy Schubert
319*7f2fe78bSCy Schubert    shell% kadmin
320*7f2fe78bSCy Schubert    kadmin: addprinc -randkey host/kerberos.mit.edu
321*7f2fe78bSCy Schubert    No policy specified for "host/kerberos.mit.edu@ATHENA.MIT.EDU"; assigning "default"
322*7f2fe78bSCy Schubert    Principal "host/kerberos.mit.edu@ATHENA.MIT.EDU" created.
323*7f2fe78bSCy Schubert
324*7f2fe78bSCy Schubert    kadmin: addprinc -randkey host/kerberos-1.mit.edu
325*7f2fe78bSCy Schubert    No policy specified for "host/kerberos-1.mit.edu@ATHENA.MIT.EDU"; assigning "default"
326*7f2fe78bSCy Schubert    Principal "host/kerberos-1.mit.edu@ATHENA.MIT.EDU" created.
327*7f2fe78bSCy Schubert
328*7f2fe78bSCy SchubertIt is not strictly necessary to have the primary KDC server in the
329*7f2fe78bSCy SchubertKerberos database, but it can be handy if you want to be able to swap
330*7f2fe78bSCy Schubertthe primary KDC with one of the replicas.
331*7f2fe78bSCy Schubert
332*7f2fe78bSCy SchubertNext, extract ``host`` random keys for all participating KDCs and
333*7f2fe78bSCy Schubertstore them in each host's default keytab file.  Ideally, you should
334*7f2fe78bSCy Schubertextract each keytab locally on its own KDC.  If this is not feasible,
335*7f2fe78bSCy Schubertyou should use an encrypted session to send them across the network.
336*7f2fe78bSCy SchubertTo extract a keytab directly on a replica KDC called
337*7f2fe78bSCy Schubert``kerberos-1.mit.edu``, you would execute the following command::
338*7f2fe78bSCy Schubert
339*7f2fe78bSCy Schubert    kadmin: ktadd host/kerberos-1.mit.edu
340*7f2fe78bSCy Schubert    Entry for principal host/kerberos-1.mit.edu with kvno 2, encryption
341*7f2fe78bSCy Schubert        type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
342*7f2fe78bSCy Schubert    Entry for principal host/kerberos-1.mit.edu with kvno 2, encryption
343*7f2fe78bSCy Schubert        type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
344*7f2fe78bSCy Schubert    Entry for principal host/kerberos-1.mit.edu with kvno 2, encryption
345*7f2fe78bSCy Schubert        type aes256-cts-hmac-sha384-192 added to keytab FILE:/etc/krb5.keytab.
346*7f2fe78bSCy Schubert    Entry for principal host/kerberos-1.mit.edu with kvno 2, encryption
347*7f2fe78bSCy Schubert        type arcfour-hmac added to keytab FILE:/etc/krb5.keytab.
348*7f2fe78bSCy Schubert
349*7f2fe78bSCy SchubertIf you are instead extracting a keytab for the replica KDC called
350*7f2fe78bSCy Schubert``kerberos-1.mit.edu`` on the primary KDC, you should use a dedicated
351*7f2fe78bSCy Schuberttemporary keytab file for that machine's keytab::
352*7f2fe78bSCy Schubert
353*7f2fe78bSCy Schubert    kadmin: ktadd -k /tmp/kerberos-1.keytab host/kerberos-1.mit.edu
354*7f2fe78bSCy Schubert    Entry for principal host/kerberos-1.mit.edu with kvno 2, encryption
355*7f2fe78bSCy Schubert        type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
356*7f2fe78bSCy Schubert    Entry for principal host/kerberos-1.mit.edu with kvno 2, encryption
357*7f2fe78bSCy Schubert        type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
358*7f2fe78bSCy Schubert
359*7f2fe78bSCy SchubertThe file ``/tmp/kerberos-1.keytab`` can then be installed as
360*7f2fe78bSCy Schubert``/etc/krb5.keytab`` on the host ``kerberos-1.mit.edu``.
361*7f2fe78bSCy Schubert
362*7f2fe78bSCy Schubert
363*7f2fe78bSCy SchubertConfigure replica KDCs
364*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~
365*7f2fe78bSCy Schubert
366*7f2fe78bSCy SchubertDatabase propagation copies the contents of the primary's database,
367*7f2fe78bSCy Schubertbut does not propagate configuration files, stash files, or the kadm5
368*7f2fe78bSCy SchubertACL file.  The following files must be copied by hand to each replica
369*7f2fe78bSCy Schubert(see :ref:`mitK5defaults` for the default locations for these files):
370*7f2fe78bSCy Schubert
371*7f2fe78bSCy Schubert* krb5.conf
372*7f2fe78bSCy Schubert* kdc.conf
373*7f2fe78bSCy Schubert* kadm5.acl
374*7f2fe78bSCy Schubert* master key stash file
375*7f2fe78bSCy Schubert
376*7f2fe78bSCy SchubertMove the copied files into their appropriate directories, exactly as
377*7f2fe78bSCy Schuberton the primary KDC.  kadm5.acl is only needed to allow a replica to
378*7f2fe78bSCy Schubertswap with the primary KDC.
379*7f2fe78bSCy Schubert
380*7f2fe78bSCy SchubertThe database is propagated from the primary KDC to the replica KDCs
381*7f2fe78bSCy Schubertvia the :ref:`kpropd(8)` daemon.  You must explicitly specify the
382*7f2fe78bSCy Schubertprincipals which are allowed to provide Kerberos dump updates on the
383*7f2fe78bSCy Schubertreplica machine with a new database.  Create a file named kpropd.acl
384*7f2fe78bSCy Schubertin the KDC state directory containing the ``host`` principals for each
385*7f2fe78bSCy Schubertof the KDCs::
386*7f2fe78bSCy Schubert
387*7f2fe78bSCy Schubert    host/kerberos.mit.edu@ATHENA.MIT.EDU
388*7f2fe78bSCy Schubert    host/kerberos-1.mit.edu@ATHENA.MIT.EDU
389*7f2fe78bSCy Schubert
390*7f2fe78bSCy Schubert.. note::
391*7f2fe78bSCy Schubert
392*7f2fe78bSCy Schubert          If you expect that the primary and replica KDCs will be
393*7f2fe78bSCy Schubert          switched at some point of time, list the host principals
394*7f2fe78bSCy Schubert          from all participating KDC servers in kpropd.acl files on
395*7f2fe78bSCy Schubert          all of the KDCs.  Otherwise, you only need to list the
396*7f2fe78bSCy Schubert          primary KDC's host principal in the kpropd.acl files of the
397*7f2fe78bSCy Schubert          replica KDCs.
398*7f2fe78bSCy Schubert
399*7f2fe78bSCy SchubertThen, add the following line to ``/etc/inetd.conf`` on each KDC
400*7f2fe78bSCy Schubert(adjust the path to kpropd)::
401*7f2fe78bSCy Schubert
402*7f2fe78bSCy Schubert    krb5_prop stream tcp nowait root /usr/local/sbin/kpropd kpropd
403*7f2fe78bSCy Schubert
404*7f2fe78bSCy SchubertYou also need to add the following line to ``/etc/services`` on each
405*7f2fe78bSCy SchubertKDC, if it is not already present (assuming that the default port is
406*7f2fe78bSCy Schubertused)::
407*7f2fe78bSCy Schubert
408*7f2fe78bSCy Schubert    krb5_prop       754/tcp               # Kerberos replica propagation
409*7f2fe78bSCy Schubert
410*7f2fe78bSCy SchubertRestart inetd daemon.
411*7f2fe78bSCy Schubert
412*7f2fe78bSCy SchubertAlternatively, start :ref:`kpropd(8)` as a stand-alone daemon.  This is
413*7f2fe78bSCy Schubertrequired when incremental propagation is enabled.
414*7f2fe78bSCy Schubert
415*7f2fe78bSCy SchubertNow that the replica KDC is able to accept database propagation,
416*7f2fe78bSCy Schubertyou’ll need to propagate the database from the primary server.
417*7f2fe78bSCy Schubert
418*7f2fe78bSCy SchubertNOTE: Do not start the replica KDC yet; you still do not have a copy
419*7f2fe78bSCy Schubertof the primary's database.
420*7f2fe78bSCy Schubert
421*7f2fe78bSCy Schubert
422*7f2fe78bSCy Schubert.. _kprop_to_replicas:
423*7f2fe78bSCy Schubert
424*7f2fe78bSCy SchubertPropagate the database to each replica KDC
425*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
426*7f2fe78bSCy Schubert
427*7f2fe78bSCy SchubertFirst, create a dump file of the database on the primary KDC, as
428*7f2fe78bSCy Schubertfollows::
429*7f2fe78bSCy Schubert
430*7f2fe78bSCy Schubert    shell% kdb5_util dump /usr/local/var/krb5kdc/replica_datatrans
431*7f2fe78bSCy Schubert
432*7f2fe78bSCy SchubertThen, manually propagate the database to each replica KDC, as in the
433*7f2fe78bSCy Schubertfollowing example::
434*7f2fe78bSCy Schubert
435*7f2fe78bSCy Schubert    shell% kprop -f /usr/local/var/krb5kdc/replica_datatrans kerberos-1.mit.edu
436*7f2fe78bSCy Schubert
437*7f2fe78bSCy Schubert    Database propagation to kerberos-1.mit.edu: SUCCEEDED
438*7f2fe78bSCy Schubert
439*7f2fe78bSCy SchubertYou will need a script to dump and propagate the database. The
440*7f2fe78bSCy Schubertfollowing is an example of a Bourne shell script that will do this.
441*7f2fe78bSCy Schubert
442*7f2fe78bSCy Schubert.. note::
443*7f2fe78bSCy Schubert
444*7f2fe78bSCy Schubert          Remember that you need to replace ``/usr/local/var/krb5kdc``
445*7f2fe78bSCy Schubert          with the name of the KDC state directory.
446*7f2fe78bSCy Schubert
447*7f2fe78bSCy Schubert::
448*7f2fe78bSCy Schubert
449*7f2fe78bSCy Schubert    #!/bin/sh
450*7f2fe78bSCy Schubert
451*7f2fe78bSCy Schubert    kdclist = "kerberos-1.mit.edu kerberos-2.mit.edu"
452*7f2fe78bSCy Schubert
453*7f2fe78bSCy Schubert    kdb5_util dump /usr/local/var/krb5kdc/replica_datatrans
454*7f2fe78bSCy Schubert
455*7f2fe78bSCy Schubert    for kdc in $kdclist
456*7f2fe78bSCy Schubert    do
457*7f2fe78bSCy Schubert        kprop -f /usr/local/var/krb5kdc/replica_datatrans $kdc
458*7f2fe78bSCy Schubert    done
459*7f2fe78bSCy Schubert
460*7f2fe78bSCy SchubertYou will need to set up a cron job to run this script at the intervals
461*7f2fe78bSCy Schubertyou decided on earlier (see :ref:`db_prop`).
462*7f2fe78bSCy Schubert
463*7f2fe78bSCy SchubertNow that the replica KDC has a copy of the Kerberos database, you can
464*7f2fe78bSCy Schubertstart the krb5kdc daemon::
465*7f2fe78bSCy Schubert
466*7f2fe78bSCy Schubert    shell% krb5kdc
467*7f2fe78bSCy Schubert
468*7f2fe78bSCy SchubertAs with the primary KDC, you will probably want to add this command to
469*7f2fe78bSCy Schubertthe KDCs' ``/etc/rc`` or ``/etc/inittab`` files, so they will start
470*7f2fe78bSCy Schubertthe krb5kdc daemon automatically at boot time.
471*7f2fe78bSCy Schubert
472*7f2fe78bSCy Schubert
473*7f2fe78bSCy SchubertPropagation failed?
474*7f2fe78bSCy Schubert###################
475*7f2fe78bSCy Schubert
476*7f2fe78bSCy SchubertYou may encounter the following error messages. For a more detailed
477*7f2fe78bSCy Schubertdiscussion on possible causes and solutions click on the error link
478*7f2fe78bSCy Schubertto be redirected to :ref:`troubleshoot` section.
479*7f2fe78bSCy Schubert
480*7f2fe78bSCy Schubert.. include:: ./troubleshoot.rst
481*7f2fe78bSCy Schubert   :start-after:  _prop_failed_start:
482*7f2fe78bSCy Schubert   :end-before: _prop_failed_end:
483*7f2fe78bSCy Schubert
484*7f2fe78bSCy Schubert
485*7f2fe78bSCy SchubertAdd Kerberos principals to the database
486*7f2fe78bSCy Schubert---------------------------------------
487*7f2fe78bSCy Schubert
488*7f2fe78bSCy SchubertOnce your KDCs are set up and running, you are ready to use
489*7f2fe78bSCy Schubert:ref:`kadmin(1)` to load principals for your users, hosts, and other
490*7f2fe78bSCy Schubertservices into the Kerberos database.  This procedure is described
491*7f2fe78bSCy Schubertfully in :ref:`principals`.
492*7f2fe78bSCy Schubert
493*7f2fe78bSCy SchubertYou may occasionally want to use one of your replica KDCs as the
494*7f2fe78bSCy Schubertprimary.  This might happen if you are upgrading the primary KDC, or
495*7f2fe78bSCy Schubertif your primary KDC has a disk crash.  See the following section for
496*7f2fe78bSCy Schubertthe instructions.
497*7f2fe78bSCy Schubert
498*7f2fe78bSCy Schubert
499*7f2fe78bSCy Schubert.. _switch_primary_replica:
500*7f2fe78bSCy Schubert
501*7f2fe78bSCy SchubertSwitching primary and replica KDCs
502*7f2fe78bSCy Schubert----------------------------------
503*7f2fe78bSCy Schubert
504*7f2fe78bSCy SchubertYou may occasionally want to use one of your replica KDCs as the
505*7f2fe78bSCy Schubertprimary.  This might happen if you are upgrading the primary KDC, or
506*7f2fe78bSCy Schubertif your primary KDC has a disk crash.
507*7f2fe78bSCy Schubert
508*7f2fe78bSCy SchubertAssuming you have configured all of your KDCs to be able to function
509*7f2fe78bSCy Schubertas either the primary KDC or a replica KDC (as this document
510*7f2fe78bSCy Schubertrecommends), all you need to do to make the changeover is:
511*7f2fe78bSCy Schubert
512*7f2fe78bSCy SchubertIf the primary KDC is still running, do the following on the *old*
513*7f2fe78bSCy Schubertprimary KDC:
514*7f2fe78bSCy Schubert
515*7f2fe78bSCy Schubert#. Kill the kadmind process.
516*7f2fe78bSCy Schubert#. Disable the cron job that propagates the database.
517*7f2fe78bSCy Schubert#. Run your database propagation script manually, to ensure that the
518*7f2fe78bSCy Schubert   replicas all have the latest copy of the database (see
519*7f2fe78bSCy Schubert   :ref:`kprop_to_replicas`).
520*7f2fe78bSCy Schubert
521*7f2fe78bSCy SchubertOn the *new* primary KDC:
522*7f2fe78bSCy Schubert
523*7f2fe78bSCy Schubert#. Start the :ref:`kadmind(8)` daemon (see :ref:`start_kdc_daemons`).
524*7f2fe78bSCy Schubert#. Set up the cron job to propagate the database (see
525*7f2fe78bSCy Schubert   :ref:`kprop_to_replicas`).
526*7f2fe78bSCy Schubert#. Switch the CNAMEs of the old and new primary KDCs.  If you can't do
527*7f2fe78bSCy Schubert   this, you'll need to change the :ref:`krb5.conf(5)` file on every
528*7f2fe78bSCy Schubert   client machine in your Kerberos realm.
529*7f2fe78bSCy Schubert
530*7f2fe78bSCy Schubert
531*7f2fe78bSCy SchubertIncremental database propagation
532*7f2fe78bSCy Schubert--------------------------------
533*7f2fe78bSCy Schubert
534*7f2fe78bSCy SchubertIf you expect your Kerberos database to become large, you may wish to
535*7f2fe78bSCy Schubertset up incremental propagation to replica KDCs.  See
536*7f2fe78bSCy Schubert:ref:`incr_db_prop` for details.
537