If ticket is expired, reacquire credentials instead of renewing
[heimdal.git] / doc / setup.texi
blob417bdae83f77cb80528461effd77a95f7877ad69
1 @c $Id$
3 @node Setting up a realm, Applications, Building and Installing, Top
5 @chapter Setting up a realm
7 @menu
8 * Configuration file::
9 * Creating the database::
10 * Modifying the database::
11 * keytabs::
12 * Serving Kerberos 4/524/kaserver::
13 * Remote administration::
14 * Password changing::
15 * Testing clients and servers::
16 * Slave Servers::
17 * Incremental propagation::
18 * Salting::
19 * Cross realm::
20 * Transit policy::
21 * Setting up DNS::
22 * Using LDAP to store the database::
23 * Providing Kerberos credentials to servers and programs::
24 @end menu
27 @cindex realm
28 realm is an administrative domain.  The name of a Kerberos realm is
29 usually the Internet domain name in uppercase.  Call your realm the same
30 as your Internet domain name if you do not have strong reasons for not
31 doing so.  It will make life easier for you and everyone else.
33 @node  Configuration file, Creating the database, Setting up a realm, Setting up a realm
34 @section Configuration file
36 To setup a realm you will first have to create a configuration file:
37 @file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many
38 configuration options, some of which are described here.
40 There is a sample @file{krb5.conf} supplied with the distribution.
42 The configuration file is a hierarchical structure consisting of
43 sections, each containing a list of bindings (either variable
44 assignments or subsections). A section starts with
45 @samp{[@samp{section-name}]}.  A binding consists of a left hand side, an equal
46 (@samp{=}) and a right hand side (the left hand side tag must be
47 separated from the equal with some whitespace). Subsections has a
48 @samp{@{} as the first non-whitespace character after the equal. All
49 other bindings are treated as variable assignments. The value of a
50 variable extends to the end of the line.
52 @example
53 [section1]
54         a-subsection = @{
55                 var = value1
56                 other-var = value with @{@}
57                 sub-sub-section = @{ 
58                         var = 123
59                 @}
60         @}
61         var = some other value
62 [section2]
63         var = yet another value
64 @end example
66 In this manual, names of sections and bindings will be given as strings
67 separated by slashes (@samp{/}). The @samp{other-var} variable will thus
68 be @samp{section1/a-subsection/other-var}.
70 For in-depth information about the contents of the configuration file, refer to
71 the @file{krb5.conf} manual page. Some of the more important sections
72 are briefly described here.
74 The @samp{libdefaults} section contains a list of library configuration
75 parameters, such as the default realm and the timeout for KDC
76 responses. The @samp{realms} section contains information about specific
77 realms, such as where they hide their KDC@. This section serves the same
78 purpose as the Kerberos 4 @file{krb.conf} file, but can contain more
79 information. Finally the @samp{domain_realm} section contains a list of
80 mappings from domains to realms, equivalent to the Kerberos 4
81 @file{krb.realms} file.
83 To continue with the realm setup, you will have to create a configuration file,
84 with contents similar to the following.
86 @example
87 [libdefaults]
88         default_realm = MY.REALM
89 [realms]
90         MY.REALM = @{
91                 kdc = my.kdc my.slave.kdc
92                 kdc = my.third.kdc
93         @}
94 [domain_realm]
95         .my.domain = MY.REALM
97 @end example
99 If you use a realm name equal to your domain name, you can omit the
100 @samp{libdefaults}, and @samp{domain_realm}, sections. If you have a DNS
101 SRV-record for your realm, or your Kerberos server has DNS CNAME
102 @samp{kerberos.my.realm}, you can omit the @samp{realms} section too.
104 @node Creating the database, Modifying the database, Configuration file, Setting up a realm
105 @section Creating the database
107 The database library will look for the database in the directory
108 @file{/var/heimdal}, so you should probably create that directory.
109 Make sure the directory has restrictive permissions.
111 @example
112 # mkdir /var/heimdal
113 @end example
115 The keys of all the principals are stored in the database.  If you
116 choose to, these can be encrypted with a master key.  You do not have to
117 remember this key (or password), but just to enter it once and it will
118 be stored in a file (@file{/var/heimdal/m-key}).  If you want to have a
119 master key, run @samp{kstash} to create this master key:
121 @example
122 # kstash
123 Master key: 
124 Verifying password - Master key: 
125 @end example
127 If you want to generate a random master key you can use the
128 --random-key to kstash. This will make sure you have a good key
129 on which attackers can't do a dictionary attack.
131 If you have a master key, make sure you make a backup of your master
132 key file; without it backups of the database are of no use.
134 To initialise the database use the @command{kadmin} program, with the
135 @samp{-l} option (to enable local database mode). First issue a
136 @kbd{init MY.REALM} command. This will create the database and insert
137 default principals for that realm. You can have more than one realm in
138 one database, so @samp{init} does not destroy any old database.
140 Before creating the database, @samp{init} will ask you some questions
141 about maximum ticket lifetimes.
143 After creating the database you should probably add yourself to it. You
144 do this with the @samp{add} command. It takes as argument the name of a
145 principal. The principal should contain a realm, so if you haven't set up
146 a default realm, you will need to explicitly include the realm.
148 @example
149 # kadmin -l
150 kadmin> init MY.REALM
151 Realm max ticket life [unlimited]:
152 Realm max renewable ticket life [unlimited]:
153 kadmin> add me  
154 Max ticket life [unlimited]:
155 Max renewable life [unlimited]:
156 Attributes []:
157 Password: 
158 Verifying password - Password: 
159 @end example
161 Now start the KDC and try getting a ticket.
163 @example
164 # kdc &
165 # kinit me
166 me@@MY.REALMS's Password:
167 # klist
168 Credentials cache: /tmp/krb5cc_0
169         Principal: me@@MY.REALM
171   Issued           Expires          Principal
172 Aug 25 07:25:55  Aug 25 17:25:55  krbtgt/MY.REALM@@MY.REALM
173 @end example
175 If you are curious you can use the @samp{dump} command to list all the
176 entries in the database.  It should look something similar to the
177 following example (note that the entries here are truncated for
178 typographical reasons):
180 @smallexample
181 kadmin> dump
182 me@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ...
183 kadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ...
184 krbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ...
185 kadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ...
186 @end smallexample
188 @node Modifying the database, keytabs, Creating the database, Setting up a realm
189 @section Modifying the database
191 All modifications of principals are done with with kadmin.
193 A principal have several attributes and lifetimes associated with it.
195 Principals are added, renamed, modified, and deleted with the kadmin
196 commands @samp{add}, @samp{rename}, @samp{modify}, @samp{delete}.
197 Both interactive editing and command switches can be used (use --help
198 to list the available options).
200 There are different kind of types for the fields in the database,
201 attributes, absolute time times and relative times.
203 @subsection Attributes
205 When doing interactive editing, attributes are listed with @samp{?}.
207 The attributes are given in a comma (@samp{,}) separated list.
208 Attributes are removed from the list by prefixing them with @samp{-}.
210 @smallexample
211 kadmin> modify me
212 Max ticket life [1 day]:
213 Max renewable life [1 week]:
214 Principal expiration time [never]:
215 Password expiration time [never]:
216 Attributes [disallow-renewable]: requires-pre-auth,-disallow-renewable
217 kadmin> get me
218             Principal: me@@MY.REALM
219 [...]
220            Attributes: requires-pre-auth
221 @end smallexample
223 @subsection Absolute times
225 The format for absolute times are any of the following
227 @smallexample
228 never
230 YYYY-mm-dd
231 YYYY-mm-dd HH:MM:SS
232 @end smallexample
235 @subsection Relative times
237 The format for relative times are any of the following combined
239 @smallexample
240 N year
241 M month
242 O day
243 P hour
244 Q minute
245 R second
246 @end smallexample
248 @c Describe more of kadmin commands here...
250 @node keytabs, Serving Kerberos 4/524/kaserver, Modifying the database, Setting up a realm
251 @section keytabs
253 To extract a service ticket from the database and put it in a keytab, you
254 need to first create the principal in the database with @samp{ank}
255 (using the @kbd{--random-key} flag to get a random key) and then
256 extract it with @samp{ext_keytab}.
258 @example
259 kadmin> add --random-key host/my.host.name
260 Max ticket life [unlimited]:
261 Max renewable life [unlimited]:
262 Attributes []:
263 kadmin> ext host/my.host.name
264 kadmin> exit
265 # ktutil list
266 Version  Type             Principal
267      1   des-cbc-md5      host/my.host.name@@MY.REALM
268      1   des-cbc-md4      host/my.host.name@@MY.REALM
269      1   des-cbc-crc      host/my.host.name@@MY.REALM
270      1   des3-cbc-sha1    host/my.host.name@@MY.REALM
271 @end example
273 @node Serving Kerberos 4/524/kaserver, Remote administration, keytabs, Setting up a realm
274 @section Serving Kerberos 4/524/kaserver
276 Heimdal can be configured to support 524, Kerberos 4 or kaserver. All
277 these services turned off by default. Kerberos 4 support also
278 depends on if Kerberos 4 support being compiled in with Heimdal.
280 @subsection 524
282 524 is a service that allows the KDC to convert Kerberos 5 tickets to
283 Kerberos 4 tickets for backward compatibility. See also Using 2b
284 tokens with AFS in @xref{Things in search for a better place}.
286 524 can be turned on by adding this to the configuration file
288 @example
289 [kdc]
290         enable-524 = yes
291 @end example
293 @subsection Kerberos 4
295 Kerberos 4 is the predecessor to to Kerberos 5. It only supports single
296 DES@. You should only enable Kerberos 4 support if you have a need for
297 for compatibility with an installed base of Kerberos 4 clients/servers.
299 Kerberos 4 can be turned on by adding this to the configuration file
301 @example
302 [kdc]
303         enable-kerberos4 = yes
304 @end example
306 @subsection kaserver
308 Kaserver is a Kerberos 4 that is used in AFS@.  The protocol have some extra
309 features over plain Kerberos 4, but like Kerberos 4, only use single
310 DES@.
312 You should only enable Kaserver support if you have a need for for
313 compatibility with an installed base of AFS machines.
315 Kaserver can be turned on by adding this to the configuration file
317 @example
318 [kdc]
319         enable-kaserver = yes
320 @end example
322 @node Remote administration, Password changing, Serving Kerberos 4/524/kaserver, Setting up a realm
323 @section Remote administration
325 The administration server, @command{kadmind}, can be started by
326 @command{inetd} (which isn't recommended) or run as a normal daemon. If you
327 want to start it from @command{inetd} you should add a line similar to the
328 one below to your @file{/etc/inetd.conf}.
330 @example
331 kerberos-adm stream     tcp     nowait  root /usr/heimdal/libexec/kadmind kadmind
332 @end example
334 You might need to add @samp{kerberos-adm} to your @file{/etc/services}
335 as @samp{749/tcp}.
337 Access to the administration server is controlled by an ACL file, (default
338 @file{/var/heimdal/kadmind.acl}.) The lines in the access file, have the
339 following syntax:
340 @smallexample
341 principal       [priv1,priv2,...]       [glob-pattern]
342 @end smallexample
344 The matching is from top to bottom for matching principals (and if given,
345 glob-pattern).  When there is a match, the access rights of that line are
346 used.
348 The privileges you can assign to a principal are: @samp{add},
349 @samp{change-password} (or @samp{cpw} for short), @samp{delete},
350 @samp{get}, @samp{list}, and @samp{modify}, or the special privilege
351 @samp{all}. All of these roughly corresponds to the different commands
352 in @command{kadmin}.
354 If a @var{glob-pattern} is given on a line, it restricts the access rights for
355 the principal to only apply for the subjects that match the pattern.
356 The patterns are of the same type as those used in shell globbing, see
357 @url{none,,fnmatch(3)}.
359 In the example below @samp{lha/admin} can change every principal in the
360 database. @samp{jimmy/admin} can only modify principals that belong to
361 the realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the
362 help desk, so he should only be able to change the passwords for single
363 component principals (ordinary users). He will not be able to change any
364 @samp{/admin} principal.
366 @example
367 lha/admin@@E.KTH.SE     all
368 jimmy/admin@@E.KTH.SE   all             *@@E.KTH.SE
369 jimmy/admin@@E.KTH.SE   all             */*@@E.KTH.SE
370 mille/admin@@E.KTH.SE   change-password *@@E.KTH.SE
371 @end example
373 @node Password changing, Testing clients and servers, Remote administration, Setting up a realm
374 @section Password changing
376 To allow users to change their passwords, you should run @command{kpasswdd}.
377 It is not run from @command{inetd}.
379 You might need to add @samp{kpasswd} to your @file{/etc/services} as
380 @samp{464/udp}.
382 @subsection Password quality assurance
384 It is important that users have good passwords, both to make it harder
385 to guess them and to avoid off-line attacks (although
386 pre-authentication provides
387 some defense against off-line attacks).  To ensure that the users choose
388 good passwords, you can enable password quality controls in
389 @command{kpasswdd} and @command{kadmind}.  The controls themselves are
390 done in a shared library or an external program that is used by
391 @command{kpasswdd}.  To configure in these controls, add
392 lines similar to the following to your @file{/etc/krb5.conf}:
394 @example
395 [password_quality]
396         policies = external-check builtin:minimum-length module:policyname
397         external_program = /bin/false
398         policy_libraries = @var{library1.so} @var{library2.so}
399 @end example
401 In @samp{[password_quality]policies} the module name is optional if
402 the policy name is unique in all modules (members of
403 @samp{policy_libraries}).
405 The builtin polices are
407 @itemize @bullet
409 @item external-check
411 Executes the program specified by @samp{[password_quality]external_program}. 
413 A number of key/value pairs is passed as input to the program, one per
414 line, ending with the string @samp{end}.  The key/value lines are of
415 the form
416 @example
417 principal: @var{principal}
418 new-password: @var{password}
419 @end example
420 where @var{password} is the password to check for the previous
421 @var{principal}.
423 If the external application approves the password, it should return
424 @samp{APPROVED} on standard out and exit with exit code 0.  If it
425 doesn't approve the password, a one line error message explaining the
426 problem should be returned on standard error and the application
427 should exit with exit code 0.  In case of a fatal error, the
428 application should, if possible, print an error message on standard
429 error and exit with a non-zero error code.
431 @item minimum-length
433 The minimum length password quality check reads the configuration file
434 stanza @samp{[password_quality]min_length} and requires the password
435 to be at least this length.
437 @item character-class
439 The character-class password quality check reads the configuration
440 file stanza @samp{[password_quality]min_classes}. The policy requires
441 the password to have characters from at least that many characters
442 classes. Default value if not given is 3.
444 The four diffrent characters classes are, uppercase, lowercase,
445 number, special characters.
447 @end itemize
449 If you want to write you own shared object that checks password
450 policies, see the manual page @manpage{kadm5_pwcheck,3}.
452 Code for a password quality checking function that uses the cracklib
453 library can be found in @file{lib/kadm5/sample_password_check.c} in the
454 source code distribution.  It requires the cracklib library built with
455 the patch available at
456 @url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}.
458 A sample policy external program is included in
459 @file{lib/kadm5/check-cracklib.pl}.
461 If no password quality checking function is configured, it is only
462 verified that it is at least six characters long.
464 @node Testing clients and servers, Slave Servers, Password changing, Setting up a realm
465 @section Testing clients and servers
467 Now you should be able to run all the clients and servers.  Refer to the
468 appropriate man pages for information on how to use them.
470 @node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm
471 @section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm
473 It is desirable to have at least one backup (slave) server in case the
474 master server fails. It is possible to have any number of such slave
475 servers but more than three usually doesn't buy much more redundancy.
477 All Kerberos servers for a realm must have the same database so that
478 they present the same service to all the users.  The
479 @pindex hprop
480 @command{hprop} program, running on the master, will propagate the database
481 to the slaves, running
482 @pindex hpropd
483 @command{hpropd} processes.
485 Every slave needs a database directory, the master key (if it was used
486 for the database) and a keytab with the principal
487 @samp{hprop/@var{hostname}}.  Add the principal with the
488 @pindex ktutil
489 @command{ktutil} command and start
490 @pindex hpropd
491 @command{hpropd}, as follows:
493 @example
494 slave# ktutil get -p foo/admin hprop/`hostname`
495 slave# mkdir /var/heimdal
496 slave# hpropd
497 @end example
499 The master will use the principal @samp{kadmin/hprop} to authenticate to
500 the slaves.  This principal should be added when running @kbd{kadmin -l
501 init} but if you do not have it in your database for whatever reason,
502 please add it with @kbd{kadmin -l add}.
504 Then run
505 @pindex hprop
506 @code{hprop} on the master:
508 @example
509 master# hprop slave
510 @end example
512 This was just an hands-on example to make sure that everything was
513 working properly.  Doing it manually is of course the wrong way, and to
514 automate this you will want to start
515 @pindex hpropd
516 @command{hpropd} from @command{inetd} on the slave(s) and regularly run
517 @pindex hprop
518 @command{hprop} on the master to regularly propagate the database.
519 Starting the propagation once an hour from @command{cron} is probably a
520 good idea.
522 @node Incremental propagation, Salting , Slave Servers, Setting up a realm
523 @section Incremental propagation
525 There is also a newer, and still somewhat experimental, mechanism for
526 doing incremental propagation in Heimdal.  Instead of sending the whole
527 database regularly, it sends the changes as they happen on the master to
528 the slaves.  The master keeps track of all the changes by assigning a
529 version number to every change to the database.  The slaves know which
530 was the latest version they saw and in this way it can be determined if
531 they are in sync or not.  A log of all the changes is kept on the master,
532 and when a slave is at an older version than the oldest one in the
533 log, the whole database has to be sent.
535 Protocol-wise, all the slaves connect to the master and as a greeting
536 tell it the latest version that they have (@samp{IHAVE} message).  The
537 master then responds by sending all the changes between that version and
538 the current version at the master (a series of @samp{FORYOU} messages)
539 or the whole database in a @samp{TELLYOUEVERYTHING} message.  There is
540 also a keep alive protocol that make sure all slaves are upp and running.
542 @subsection Configuring incremental propagation
544 The program that runs on the master is @command{ipropd-master} and all
545 clients run @command{ipropd-slave}.
547 Create the file @file{/var/heimdal/slaves} on the master containing all
548 the slaves that the database should be propagated to.  Each line contains
549 the full name of the principal (for example
550 @samp{iprop/hemligare.foo.se@@FOO.SE}).
552 You should already have @samp{iprop/tcp} defined as 2121, in your
553 @file{/etc/services}.  Otherwise, or if you need to use a different port
554 for some peculiar reason, you can use the @kbd{--port} option.  This is
555 useful when you have multiple realms to distribute from one server.
557 Then you need to create those principals that you added in the
558 configuration file.  Create one @samp{iprop/hostname} for the master and
559 for every slave.
562 @example
563 master# /usr/heimdal/sbin/ktutil get iprop/`hostname`
564 @end example
566 The next step is to start the @command{ipropd-master} process on the master
567 server.  The @command{ipropd-master} listens on the UNIX domain socket
568 @file{/var/heimdal/signal} to know when changes have been made to the
569 database so they can be propagated to the slaves.  There is also a
570 safety feature of testing the version number regularly (every 30
571 seconds) to see if it has been modified by some means that do not raise
572 this signal.  Then, start @command{ipropd-slave} on all the slaves:
574 @example
575 master# /usr/heimdal/libexec/ipropd-master &
576 slave#  /usr/heimdal/libexec/ipropd-slave master &
577 @end example
579 @node Salting, Cross realm, Incremental propagation, Setting up a realm
580 @section Salting
581 @cindex Salting
583 Salting is used to make it harder to precalculate all possible
584 keys. Using a salt increases the search space to make it almost
585 impossible to precalculate all keys. Salting is the process of mixing a
586 public string (the salt) with the password, then sending it through an
587 encryption type specific string-to-key function that will output the
588 fixed size encryption key.
590 In Kerberos 5 the salt is determined by the encryption-type, except
591 in some special cases.
593 In @code{des} there is the Kerberos 4 salt
594 (none at all) or the afs-salt (using the cell (realm in
595 AFS lingo)).
597 In @code{arcfour} (the encryption type that Microsoft Windows 2000 uses)
598 there is no salt. This is to be compatible with NTLM keys in Windows
599 NT 4.
601 @code{[kadmin]default_keys} in @file{krb5.conf} controls
602 what salting to use,
604 The syntax of @code{[kadmin]default_keys} is
605 @samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption
606 type (des, des3, arcfour), @code{salt-type} is the type of salt (pw-salt
607 or afs3-salt), and the salt-string is the string that will be used as
608 salt (remember that if the salt is appended/prepended, the empty salt ""
609 is the same thing as no salt at all).
611 Common types of salting include
613 @itemize @bullet
614 @item @code{v4} (or @code{des:pw-salt:})
616 The Kerberos 4 salting is using no salt at all. Reason there is colon
617 at the end of the salt string is that it makes the salt the empty
618 string (same as no salt).
620 @item @code{v5} (or @code{pw-salt})
622 @code{pw-salt} uses the default salt for each encryption type is
623 specified for. If the encryption type @samp{etype} isn't given, all
624 default encryption will be used.
626 @item @code{afs3-salt}
628 @code{afs3-salt} is the salt that is used with Transarc kaserver. Its
629 the cell name appended to the password.
631 @end itemize
633 @node Cross realm, Transit policy , Salting, Setting up a realm
634 @section Cross realm
635 @cindex Cross realm
637 Suppose you reside in the realm @samp{MY.REALM}, how do you
638 authenticate to a server in @samp{OTHER.REALM}? Having valid tickets in
639 @samp{MY.REALM} allows you to communicate with Kerberised services in that
640 realm. However, the computer in the other realm does not have a secret
641 key shared with the Kerberos server in your realm.
643 It is possible to share keys between two realms that trust each
644 other. When a client program, such as @command{telnet} or @command{ssh},
645 finds that the other computer is in a different realm, it will try to
646 get a ticket granting ticket for that other realm, but from the local
647 Kerberos server. With that ticket granting ticket, it will then obtain
648 service tickets from the Kerberos server in the other realm.
650 For a two way trust between @samp{MY.REALM} and @samp{OTHER.REALM}
651 add the following principals to each realm. The principals should be
652 @samp{krbtgt/OTHER.REALM@@MY.REALM} and
653 @samp{krbtgt/MY.REALM@@OTHER.REALM} in @samp{MY.REALM}, and
654 @samp{krbtgt/MY.REALM@@OTHER.REALM} and
655 @samp{krbtgt/OTHER.REALM@@MY.REALM}in @samp{OTHER.REALM}.
657 In Kerberos 5 the trust can be configured to be one way. So that
658 users from @samp{MY.REALM} can authenticate to services in
659 @samp{OTHER.REALM}, but not the opposite. In the example above, the
660 @samp{krbtgt/MY.REALM@@OTHER.REALM} then should be removed.
662 The two principals must have the same key, key version number, and the
663 same set of encryption types. Remember to transfer the two keys in a
664 safe manner.
666 @example
667 @cartouche
668 vr$ klist
669 Credentials cache: FILE:/tmp/krb5cc_913.console
670         Principal: lha@@E.KTH.SE
672   Issued           Expires          Principal                   
673 May  3 13:55:52  May  3 23:55:54  krbtgt/E.KTH.SE@@E.KTH.SE      
675 vr$ telnet -l lha hummel.it.su.se
676 Trying 2001:6b0:5:1095:250:fcff:fe24:dbf...
677 Connected to hummel.it.su.se.
678 Escape character is '^]'.
679 Waiting for encryption to be negotiated...
680 [ Trying mutual KERBEROS5 (host/hummel.it.su.se@@SU.SE)... ]
681 [ Kerberos V5 accepts you as ``lha@@E.KTH.SE'' ]
682 Encryption negotiated.
683 Last login: Sat May  3 14:11:47 from vr.l.nxs.se
684 hummel$ exit
686 vr$ klist
687 Credentials cache: FILE:/tmp/krb5cc_913.console
688         Principal: lha@@E.KTH.SE
690   Issued           Expires          Principal                   
691 May  3 13:55:52  May  3 23:55:54  krbtgt/E.KTH.SE@@E.KTH.SE      
692 May  3 13:55:56  May  3 23:55:54  krbtgt/SU.SE@@E.KTH.SE         
693 May  3 14:10:54  May  3 23:55:54  host/hummel.it.su.se@@SU.SE    
695 @end cartouche
696 @end example
698 @node Transit policy, Setting up DNS , Cross realm, Setting up a realm
699 @section Transit policy
700 @cindex Transit policy
702 If you want to use cross realm authentication through an intermediate
703 realm, it must be explicitly allowed by either the KDCs or the server
704 receiving the request. This is done in @file{krb5.conf} in the
705 @code{[capaths]} section.
707 When the ticket transits through a realm to another realm, the
708 destination realm adds its peer to the "transited-realms" field in the
709 ticket. The field is unordered, since there is no way to know if
710 know if one of the transited-realms changed the order of the list.
712 The syntax for @code{[capaths]} section:
714 @example
715 @cartouche
716 [capaths]
717         CLIENT-REALM = @{
718                 SERVER-REALM = PERMITTED-CROSS-REALMS ...
719         @}
720 @end cartouche
721 @end example
723 The realm @code{STACKEN.KTH.SE} allows clients from @code{SU.SE} and
724 @code{DSV.SU.SE} to cross it. Since @code{STACKEN.KTH.SE} only have
725 direct cross realm with @code{KTH.SE}, and @code{DSV.SU.SE} only have direct cross
726 realm with @code{SU.SE} they need to use both @code{SU.SE} and
727 @code{KTH.SE} as transit realms.
729 @example
730 @cartouche
731 [capaths]
732         SU.SE = @{
733                     STACKEN.KTH.SE = KTH.SE
734         @}
735         DSV.SU.SE = @{
736                     STACKEN.KTH.SE = SU.SE KTH.SE
737         @}
739 @end cartouche
740 @end example
742 The order of the @code{PERMITTED-CROSS-REALMS} is not important when
743 doing transit cross realm verification.
745 However the order is important when the @code{[capaths]} section is used
746 to figure out the intermediate realm to go to when doing multi-realm
747 transit. When figuring out the next realm, the first realm of the list
748 of @code{PERMITTED-CROSS-REALMS} is chosen. This is done in both the
749 client kerberos library and the KDC.
751 @c To test the cross realm configuration, use:
752 @c    kmumble transit-check client server transit-realms ...
754 @node Setting up DNS, Using LDAP to store the database, Transit policy, Setting up a realm
755 @section Setting up DNS
756 @cindex Setting up DNS
758 @subsection Using DNS to find KDC
760 If there is information about where to find the KDC or kadmind for a
761 realm in the @file{krb5.conf} for a realm, that information will be
762 preferred, and DNS will not be queried.
764 Heimdal will try to use DNS to find the KDCs for a realm. First it
765 will try to find a @code{SRV} resource record (RR) for the realm. If no
766 SRV RRs are found, it will fall back to looking for an @code{A} RR for
767 a machine named kerberos.REALM, and then kerberos-1.REALM, etc
769 Adding this information to DNS makes the client have less
770 configuration (in the common case, no configuration) and allows the
771 system administrator to change the number of KDCs and on what machines
772 they are running without caring about clients.
774 The down side of using DNS that the client might be fooled to use the
775 wrong server if someone fakes DNS replies/data, but storing the IP
776 addresses of the KDC on all the clients makes it very hard to change
777 the infrastructure.
779 An example of the configuration for the realm @code{EXAMPLE.COM},
781 @example
783 $ORIGIN example.com.
784 _kerberos._tcp          SRV     10 1 88 kerberos.example.com.
785 _kerberos._udp          SRV     10 1 88 kerberos.example.com.
786 _kerberos._tcp          SRV     10 1 88 kerberos-1.example.com.
787 _kerberos._udp          SRV     10 1 88 kerberos-1.example.com.
788 _kpasswd._udp           SRV     10 1 464 kerberos.example.com.
789 _kerberos-adm._tcp      SRV     10 1 749 kerberos.example.com.
791 @end example
793 More information about DNS SRV resource records can be found in
794 RFC-2782 (A DNS RR for specifying the location of services (DNS SRV)).
796 @subsection Using DNS to map hostname to Kerberos realm
798 Heimdal also supports a way to lookup a realm from a hostname. This to
799 minimize configuration needed on clients. Using this has the drawback
800 that clients can be redirected by an attacker to realms within the
801 same cross realm trust and made to believe they are talking to the
802 right server (since Kerberos authentication will succeed).
804 An example configuration that informs clients that for the realms
805 it.example.com and srv.example.com, they should use the realm
806 EXAMPLE.COM:
808 @example
810 $ORIGIN example.com.
811 _kerberos.it            TXT     "EXAMPLE.COM"
812 _kerberos.srv           TXT     "EXAMPLE.COM"
814 @end example
816 @node Using LDAP to store the database, Providing Kerberos credentials to servers and programs, Setting up DNS, Setting up a realm
817 @section Using LDAP to store the database
818 @cindex Using the LDAP backend
820 This document describes how to install the LDAP backend for
821 Heimdal. Note that before attempting to configure such an
822 installation, you should be aware of the implications of storing
823 private information (such as users' keys) in a directory service
824 primarily designed for public information. Nonetheless, with a
825 suitable authorization policy, it is possible to set this up in a
826 secure fashion. A knowledge of LDAP, Kerberos, and C is necessary to
827 install this backend. The HDB schema was devised by Leif Johansson.
829 Requirements:
831 @itemize @bullet
833 @item
834 A current release of Heimdal, configured with
835 @code{--with-openldap=/usr/local} (adjust according to where you have
836 installed OpenLDAP).
838 You can verify that you manage to configure LDAP support by running
839 @file{kdc --builtin-hdb}, and checking that @samp{ldap:} is one entry
840 in the list.
842 Its also possible to configure the ldap backend as a shared module,
843 see option --hdb-openldap-module to configure.
845 @item
846 OpenLDAP 2.0.x. Configure OpenLDAP with @kbd{--enable-local} to enable the
847 local transport. (A patch to support SASL EXTERNAL authentication is
848 necessary in order to use OpenLDAP 2.1.x.)
850 @item
851 Add the hdb schema to the LDAP server, its included in the source-tree
852 in @file{lib/hdb/hdb.schema}. Example from slapd.conf:
854 @example
855 include /usr/local/etc/openldap/schema/hdb.schema
856 @end example
858 @item
859 Configure the LDAP server ACLs to accept writes from clients over the
860 local transport. For example:
862 @example
863 access to *
864         by dn.exact="uid=heimdal,dc=services,dc=example,dc=com" write
865         ...
867 sasl-regexp "uidNumber=0\\\+gidNumber=.*,cn=peercred,cn=external,cn=auth"
868         "uid=heimdal,dc=services,dc=example,dc=com"
870 @end example
872 The sasl-regexp is for mapping between the SASL/EXTERNAL and a user in
873 a tree.  The user that the key is mapped to should be have a
874 krb5Principal aux object with krb5PrincipalName set so that the
875 ``creator'' and ``modifier'' is right in @file{kadmin}.
877 Another option is to create an admins group and add the dn to that
878 group.
880 Since Heimdal talkes to the LDAP server over a UNIX domain socket, and
881 uses external sasl authentication, its not possible to require
882 security layer quality (ssf in cyrus-sasl lingo). So that requirement
883 has to be turned off in OpenLDAP @command{slapd} configuration file
884 @file{slapd.conf}.
886 @example
887 sasl-secprops minssf=0
888 @end example
890 @item
892 Start @command{slapd} with the local listener (as well as the default TCP/IP
893 listener on port 389) as follows:
895 @example
896     slapd -h "ldapi:/// ldap:///"
897 @end example
899 Note: These is a bug in @command{slapd} where it appears to corrupt the krb5Key
900 binary attribute on shutdown. This may be related to our use of the V3
901 schema definition syntax instead of the old UMich-style, V2 syntax.
903 @item
904 You should specify the distinguished name under which your
905 principals will be stored in @file{krb5.conf}:
907 @example
908 [kdc]
909         database = @{
910                 dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com
911                 mkey_file = /path/to/mkey
912         @}
913 @end example
915 @samp{mkey_file} can be excluded if you feel that you trust your ldap
916 directory to have the raw keys inside it.
919 @item
920 Once you have built Heimdal and started the LDAP server, run kadmin
921 (as usual) to initialize the database. Note that the instructions for
922 stashing a master key are as per any Heimdal installation.
924 @example
925 kdc# kadmin -l
926 kadmin> init EXAMPLE.COM
927 Realm max ticket life [unlimited]:
928 Realm max renewable ticket life [unlimited]:
929 kadmin> ank lukeh
930 Max ticket life [1 day]:
931 Max renewable life [1 week]:
932 Principal expiration time [never]:
933 Password expiration time [never]:
934 Attributes []:
935 lukeh@@EXAMPLE.COM's Password:
936 Verifying password - lukeh@@EXAMPLE.COM's Password:
937 kadmin> exit
938 @end example
940 Verify that the principal database has indeed been stored in the
941 directory with the following command:
943 @example
944 kdc# ldapsearch -L -h localhost -D cn=manager \
945  -w secret -b ou=KerberosPrincipals,dc=example,dc=com \
946  'objectclass=krb5KDCEntry' 
947 @end example
949 @item
950 Now consider adding indexes to the database to speed up the access, at
951 least theses should be added to slapd.conf.
953 @example
954 index   objectClass             eq
955 index   cn                      eq,sub,pres
956 index   uid                     eq,sub,pres
957 index   displayName             eq,sub,pres
958 index   krb5PrincipalName       eq
959 @end example
961 @end itemize
963 @subsection Troubleshooting guide
965 @url{https://sec.miljovern.no/bin/view/Info/TroubleshootingGuide}
968 @subsection Using Samba LDAP password database
969 @cindex Samba
971 @c @node Using Samba LDAP password database, Providing Kerberos credentials to servers and programs, Using LDAP to store the database, Setting up a realm
972 @c @section Using Samba LDAP password database
974 Samba domain and the Kerberos realm can have diffrent names since
975 arcfour's string to key function principal/realm independent.  So now
976 will be your first and only chance name your Kerberos without needing
977 to deal with old configuration files.
979 First you should set up Samba and get that working with LDAP backend.
981 Now you can proceed as in @xref{Using LDAP to store the database},
982 Heimdal will pick up the Samba LDAP entries if they are in the same
983 search space as the Kerberos entries.
985 @node Providing Kerberos credentials to servers and programs, , Using LDAP to store the database, Setting up a realm
986 @section Providing Kerberos credentials to servers and programs
988 Some service require Kerberos credentials when they start to make
989 connections to other services or use them when they have started.
991 The easiest way to get ticket for the a service is to store the key in
992 a keytab. Both ktutil get and kadmin ext can be used to get a
993 keytab. ktutil get is better in that way it changes the key/password
994 for the user. This the problem with the ktutil. It ktutil is used for
995 the same service principal on several hosts, they keytab will only
996 useful on the last host. In that case, run the command on host and
997 copy the keytab around to all other hosts that needs it.
999 @example
1000 host# ktutil -k /etc/krb5-service.keytab \
1001       get -p lha/admin@@EXAMPLE.ORG service-principal@@EXAMPLE.ORG
1002 lha/admin@@EXAMPLE.ORG's Password: 
1003 @end example
1005 To get a Kerberos credential file for the service, use kinit in the
1006 --keytab mode, this will not ask for a password but rather that the
1007 key from the keytab.
1009 @example
1010 service@@host$ kinit --cache=/var/run/service_krb5_cache \
1011                --keytab=/etc/krb5-service.keytab \
1012        service-principal@@EXAMPLE.ORG
1013 @end example
1015 Long running services might need credentials longer then the
1016 expiration time of the tickets. kinit can run in a mode that refreshes
1017 the tickets before they expire. This is useful for services that write
1018 into AFS and other distributed file systems using Kerberos. To run the
1019 long running script, just append the program and arguments (if any)
1020 after the principal. kinit will stop refreshing credentials and remove
1021 the credentials when the script-to-start-service exits.
1023 @example
1024 service@@host$ kinit --cache=/var/run/service_krb5_cache \
1025        --keytab=/etc/krb5-service.keytab \
1026        service-principal@@EXAMPLE.ORG \
1027        script-to-start-service argument1 argument2
1028 @end example