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