xref: /freebsd/crypto/heimdal/doc/setup.texi (revision bbd80c285ead4d04e4b8b9e950164352819694ba)
1@c $Id: setup.texi,v 1.27 2003/03/30 21:43:00 lha Exp $
2
3@node Setting up a realm, Things in search for a better place, Building and Installing, Top
4
5@chapter Setting up a realm
6
7@menu
8* Configuration file::
9* Creating the database::
10* keytabs::
11* Serving Kerberos 4/524/kaserver::
12* Remote administration::
13* Password changing::
14* Testing clients and servers::
15* Slave Servers::
16* Incremental propagation::
17* Salting::
18@end menu
19
20A
21@cindex realm
22realm is an administrative domain.  The name of a Kerberos realm is
23usually the Internet domain name in uppercase.  Call your realm the same
24as your Internet domain name if you do not have strong reasons for not
25doing so.  It will make life easier for you and everyone else.
26
27@node  Configuration file, Creating the database, Setting up a realm, Setting up a realm
28@section Configuration file
29
30To setup a realm you will first have to create a configuration file:
31@file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many
32configuration options, some of which are described here.
33
34There is a sample @file{krb5.conf} supplied with the distribution.
35
36The configuration file is a hierarchical structure consisting of
37sections, each containing a list of bindings (either variable
38assignments or subsections). A section starts with
39@samp{[section-name]}.  A binding consists of a left hand side, an equal
40(@samp{=}) and a right hand side (the left hand side tag must be
41separated from the equal with some whitespace.) Subsections has a
42@samp{@{} as the first non-whitespace character after the equal. All
43other bindings are treated as variable assignments. The value of a
44variable extends to the end of the line.
45
46@example
47[section1]
48        a-subsection = @{
49                var = value1
50                other-var = value with @{@}
51                sub-sub-section = @{
52                        var = 123
53                @}
54        @}
55        var = some other value
56[section2]
57        var = yet another value
58@end example
59
60In this manual, names of sections and bindings will be given as strings
61separated by slashes (@samp{/}). The @samp{other-var} variable will thus
62be @samp{section1/a-subsection/other-var}.
63
64For in-depth information about the contents of the config file, refer to
65the @file{krb5.conf} manual page. Some of the more important sections
66are briefly described here.
67
68The @samp{libdefaults} section contains a list of library configuration
69parameters, such as the default realm and the timeout for kdc
70responses. The @samp{realms} section contains information about specific
71realms, such as where they hide their KDC. This section serves the same
72purpose as the Kerberos 4 @file{krb.conf} file, but can contain more
73information. Finally the @samp{domain_realm} section contains a list of
74mappings from domains to realms, equivalent to the Kerberos 4
75@file{krb.realms} file.
76
77To continue with the realm setup, you will have to create a config file,
78with contents similar to the following.
79
80@example
81[libdefaults]
82        default_realm = MY.REALM
83[realms]
84        MY.REALM = @{
85                kdc = my.kdc
86        @}
87[domain_realm]
88        .my.domain = MY.REALM
89
90@end example
91
92If you use a realm name equal to your domain name, you can omit the
93@samp{libdefaults}, and @samp{domain_realm}, sections. If you have a
94SRV-record for your realm, or your kerberos server has CNAME called
95@samp{kerberos.my.realm}, you can omit the @samp{realms} section too.
96
97@node Creating the database, keytabs, Configuration file, Setting up a realm
98@section Creating the database
99
100The database library will look for the database in @file{/var/heimdal},
101so you should probably create that directory.
102
103The keys of all the principals are stored in the database.  If you
104choose to, these can be encrypted with a master key.  You do not have to
105remember this key (or password), but just to enter it once and it will
106be stored in a file (@file{/var/heimdal/m-key}).  If you want to have a
107master key, run @samp{kstash} to create this master key:
108
109@example
110# kstash
111Master key:
112Verifying password - Master key:
113@end example
114
115To initialise the database use the @code{kadmin} program, with the
116@samp{-l} option (to enable local database mode). First issue a
117@kbd{init MY.REALM} command. This will create the database and insert
118default principals for that realm. You can have more than one realm in
119one database, so @samp{init} does not destroy any old database.
120
121Before creating the database, @samp{init} will ask you some questions
122about max ticket lifetimes.
123
124After creating the database you should probably add yourself to it. You
125do this with the @samp{add} command. It takes as argument the name of a
126principal. The principal should contain a realm, so if you haven't setup
127a default realm, you will need to explicitly include the realm.
128
129@example
130# kadmin -l
131kadmin> init MY.REALM
132Realm max ticket life [unlimited]:
133Realm max renewable ticket life [unlimited]:
134kadmin> add me
135Max ticket life [unlimited]:
136Max renewable life [unlimited]:
137Attributes []:
138Password:
139Verifying password - Password:
140@end example
141
142Now start the KDC and try getting a ticket.
143
144@example
145# kdc &
146# kinit me
147me@@MY.REALMS's Password:
148# klist
149Credentials cache: /tmp/krb5cc_0
150        Principal: me@@MY.REALM
151
152  Issued           Expires          Principal
153Aug 25 07:25:55  Aug 25 17:25:55  krbtgt/MY.REALM@@MY.REALM
154@end example
155
156If you are curious you can use the @samp{dump} command to list all the
157entries in the database.  It should look something similar to the
158following example (note that the entries here are truncated for
159typographical reasons):
160
161@smallexample
162kadmin> dump
163me@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ...
164kadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ...
165krbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ...
166kadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ...
167@end smallexample
168
169@node keytabs, Serving Kerberos 4/524/kaserver, Creating the database, Setting up a realm
170@section keytabs
171
172To extract a service ticket from the database and put it in a keytab you
173need to first create the principal in the database with @samp{ank}
174(using the @kbd{--random-key} flag to get a random key) and then
175extract it with @samp{ext_keytab}.
176
177@example
178kadmin> add --random-key host/my.host.name
179Max ticket life [unlimited]:
180Max renewable life [unlimited]:
181Attributes []:
182kadmin> ext host/my.host.name
183# ktutil list
184Version  Type             Principal
185     1   des-cbc-md5      host/my.host.name@@MY.REALM
186     1   des-cbc-md4      host/my.host.name@@MY.REALM
187     1   des-cbc-crc      host/my.host.name@@MY.REALM
188     1   des3-cbc-sha1    host/my.host.name@@MY.REALM
189@end example
190
191@node Serving Kerberos 4/524/kaserver, Remote administration, keytabs, Setting up a realm
192@section Serving Kerberos 4/524/kaserver
193
194Heimdal can be configured to support 524, Kerberos 4 or kaserver. All
195theses services are default turned off. Kerberos 4 support also
196depends on if Kerberos 4 support is compiled in with heimdal.
197
198@subsection 524
199
200524 is a service that allows the kdc to convert Kerberos 5 tickets to
201Kerberos 4 tickets for backward compatibility. See also Using 2b
202tokens with AFS in @xref{Things in search for a better place}.
203
204524 can be turned on by adding this to the configuration file
205
206@example
207[kdc]
208	enable-524 = yes
209@end example
210
211@subsection Kerberos 4
212
213Kerberos 4 is the predecessor to to Kerberos 5. It only support single
214DES. You should only enable Kerberos 4 support if you have a need for
215for compatibility with an installed base of Kerberos 4 clients/servers.
216
217Kerberos 4 can be turned on by adding this to the configuration file
218
219@example
220[kdc]
221	enable-kerberos4 = yes
222@end example
223
224@subsection kaserver
225
226Kaserver is a Kerberos 4 that is used in AFS, the protocol have some
227features over plain Kerberos 4, but like kerberos 4 only use single
228DES too.
229
230You should only enable Kerberos 4 support if you have a need for for
231compatibility with an installed base of AFS machines.
232
233Kaserver can be turned on by adding this to the configuration file
234
235@example
236[kdc]
237	enable-kaserver = yes
238@end example
239
240@node Remote administration, Password changing, Serving Kerberos 4/524/kaserver, Setting up a realm
241@section Remote administration
242
243The administration server, @samp{kadmind}, can be started by
244@samp{inetd} (which isn't recommended) or run as a normal daemon. If you
245want to start it from @samp{inetd} you should add a line similar to the
246one below to your @file{/etc/inetd.conf}.
247
248@example
249kerberos-adm stream     tcp     nowait  root /usr/heimdal/libexec/kadmind kadmind
250@end example
251
252You might need to add @samp{kerberos-adm} to your @file{/etc/services}
253as 749/tcp.
254
255Access to the admin server is controlled by an acl-file, (default
256@file{/var/heimdal/kadmind.acl}.) The lines in the access file, has the
257following syntax:
258@smallexample
259principal       [priv1,priv2,...]       [glob-pattern]
260@end smallexample
261
262The matching is from top to bottom for matching principal (and if given,
263glob-pattern).  When there is a match, the rights of that lines are
264used.
265
266The privileges you can assign to a principal are: @samp{add},
267@samp{change-password} (or @samp{cpw} for short), @samp{delete},
268@samp{get}, @samp{list}, and @samp{modify}, or the special privilege
269@samp{all}. All of these roughly corresponds to the different commands
270in @samp{kadmin}.
271
272If a @var{glob-pattern} is given on a line, it restricts the right for
273the principal to only apply for the subjects that match the pattern.
274The patters are of the same type as those used in shell globbing, see
275@url{none,,fnmatch(3)}.
276
277In the example below @samp{lha/admin} can change every principal in the
278database. @samp{jimmy/admin} can only modify principals that belong to
279the realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the
280helpdesk, so he should only be able to change the passwords for single
281component principals (ordinary users). He will not be able to change any
282@samp{/admin} principal.
283
284@example
285lha/admin@@E.KTH.SE	all
286jimmy/admin@@E.KTH.SE	all		*@@E.KTH.SE
287jimmy/admin@@E.KTH.SE	all		*/*@@E.KTH.SE
288mille/admin@@E.KTH.SE	change-password	*@@E.KTH.SE
289@end example
290
291@node Password changing, Testing clients and servers, Remote administration, Setting up a realm
292@section Password changing
293
294To allow users to change their passwords, you should run @samp{kpasswdd}.
295It is not run from @samp{inetd}.
296
297You might need to add @samp{kpasswd} to your @file{/etc/services} as
298464/udp.
299
300@subsection Password quality assurance
301
302It is important that users have good passwords, both to make it harder
303to guess them and to avoid off-line attacks (pre-authentication provides
304some defense against off-line attacks).  To ensure that the users choose
305good passwords, you can enable password quality controls in
306@samp{kpasswdd}.  The controls themselves are done in a shared library
307that is used by @samp{kpasswdd}.  To configure in these controls, add
308lines similar to the following to your @file{/etc/krb5.conf}:
309
310@example
311[password_quality]
312        check_library = @var{library}
313        check_function = @var{function}
314@end example
315
316The function @var{function} in the shared library @var{library} will be
317called for proposed new passwords.  The function should be declared as:
318
319@example
320const char *
321function(krb5_context context, krb5_principal principal, krb5_data *pwd);
322@end example
323
324The function should verify that @var{pwd} is a good password for
325@var{principal} and if so return @code{NULL}.  If it is deemed to be of
326low quality, it should return a string explaining why that password
327should not be used.
328
329Code for a password quality checking function that uses the cracklib
330library can be found in @file{lib/kadm5/sample_password_check.c} in the
331source code distribution.  It requires the cracklib library built with
332the patch available at
333@url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}.
334
335If no password quality checking function is configured, it is only
336verified that it is at least six characters of length.
337
338@node Testing clients and servers, Slave Servers, Password changing, Setting up a realm
339@section Testing clients and servers
340
341Now you should be able to run all the clients and servers.  Refer to the
342appropriate man pages for information on how to use them.
343
344@node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm
345@section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm
346
347It is desirable to have at least one backup (slave) server in case the
348master server fails. It is possible to have any number of such slave
349servers but more than three usually doesn't buy much more redundancy.
350
351All Kerberos servers for a realm shall have the same database so that
352they present the same service to all the users.  The
353@pindex hprop
354@code{hprop} program, running on the master, will propagate the database
355to the slaves, running
356@pindex hpropd
357@code{hpropd} processes.
358
359Every slave needs a keytab with a principal,
360@samp{hprop/@var{hostname}}.  Add that with the
361@pindex ktutil
362@code{ktutil} command and start
363@pindex hpropd
364@code{propd}, as follows:
365
366@example
367slave# ktutil get -p foo/admin hprop/`hostname`
368slave# hpropd
369@end example
370
371The master will use the principal @samp{kadmin/hprop} to authenticate to
372the slaves.  This principal should be added when running @kbd{kadmin -l
373init} but if you do not have it in your database for whatever reason,
374please add it with @kbd{kadmin -l add}.
375
376Then run
377@pindex hprop
378@code{hprop} on the master:
379
380@example
381master# hprop slave
382@end example
383
384This was just an on-hands example to make sure that everything was
385working properly.  Doing it manually is of course the wrong way and to
386automate this you will want to start
387@pindex hpropd
388@code{hpropd} from @code{inetd} on the slave(s) and regularly run
389@pindex hprop
390@code{hprop} on the master to regularly propagate the database.
391Starting the propagation once an hour from @code{cron} is probably a
392good idea.
393
394@node Incremental propagation, Salting , Slave Servers, Setting up a realm
395@section Incremental propagation
396
397There is also a newer and still somewhat experimental mechanism for
398doing incremental propagation in Heimdal.  Instead of sending the whole
399database regularly, it sends the changes as they happen on the master to
400the slaves.  The master keeps track of all the changes by assigned a
401version number to every change to the database.  The slaves know which
402was the latest version they saw and in this way it can be determined if
403they are in sync or not.  A log of all the changes is kept on the master
404and when a slave is at an older versioner than the oldest one in the
405log, the whole database has to be sent.
406
407Protocol-wise, all the slaves connects to the master and as a greeting
408tell it the latest version that they have (@samp{IHAVE} message).  The
409master then responds by sending all the changes between that version and
410the current version at the master (a series of @samp{FORYOU} messages)
411or the whole database in a @samp{TELLYOUEVERYTHING} message.
412
413@subsection Configuring incremental propagation
414
415The program that runs on the master is @code{ipropd-master} and all
416clients run @code{ipropd-slave}.
417
418Create the file @file{/var/heimdal/slaves} on the master containing all
419the slaves that the database should be propagated to.  Each line contains
420the full name of the principal (for example
421@samp{iprop/hemligare.foo.se@@FOO.SE}).
422
423You should already have @samp{iprop/tcp} defined as 2121, in your
424@file{/etc/services}.  Otherwise, or if you need to use a different port
425for some peculiar reason, you can use the @kbd{--port} option.  This is
426useful when you have multiple realms to distribute from one server.
427
428Then you need to create these principals that you added in the
429configuration file.  Create one @samp{iprop/hostname} for the master and
430for every slave.
431
432
433@example
434master# /usr/heimdal/sbin/ktutil get iprop/`hostname`
435@end example
436
437The next step is to start the @code{ipropd-master} process on the master
438server.  The @code{ipropd-master} listens on the UNIX-socket
439@file{/var/heimdal/signal} to know when changes have been made to the
440database so they can be propagated to the slaves.  There is also a
441safety feature of testing the version number regularly (every 30
442seconds) to see if it has been modified by some means that do not raise
443this signal.  Then, start @code{ipropd-slave} on all the slaves:
444
445@example
446master# /usr/heimdal/libexec/ipropd-master &
447slave#  /usr/heimdal/libexec/ipropd-slave master &
448@end example
449
450@node Salting, , Incremental propagation, Setting up a realm
451@section Salting
452@cindex Salting
453
454Salting is used to make it harder to precalculate all possible
455keys. Using a salt increases the search space to make it almost
456impossible to precalculate all keys. Salting is the process of mixing a
457public string (the salt) with the password, then sending it through an
458encryption-type specific string-to-key function that will output the
459fixed size encryption key.
460
461In Kerberos 5 the salt is determined by the encryption-type, except
462in some special cases.
463
464In @code{des} there is the Kerberos 4 salt
465(none at all) or the afs-salt (using the cell (realm in
466afs-lingo)).
467
468In @code{arcfour} (the encryption type that Microsoft Windows 2000 uses)
469there is no salt. This is to be compatible with NTLM keys in Windows
470NT 4.
471
472@code{[kadmin]default_keys} in @file{krb5.conf} controls
473what salting to use,
474
475The syntax of @code{[kadmin]default_keys} is
476@samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption
477type (des, des3, arcfour), @code{salt-type} is the type of salt (pw-salt
478or afs3-salt), and the salt-string is the string that will be used as
479salt (remember that if the salt is appened/prepended, the empty salt ""
480is the same thing as no salt at all).
481
482Common types of salting includes
483
484@itemize @bullet
485@item @code{v4} (or @code{des:pw-salt:})
486
487The Kerberos 4 salting is using no salt att all. Reason there is colon
488that the end or the salt string is that it makes the salt the empty
489string (same as no salt).
490
491@item @code{v5} (or @code{pw-salt})
492
493@code{pw-salt} means all regular encryption-types that is regular
494
495@item @code{afs3-salt}
496
497@code{afs3-salt} is the salting that is used with Transarc kaserver. Its
498the cell appended to the password.
499
500@end itemize
501