3 @node Setting up a realm, Applications, Building and Installing, Top
5 @chapter Setting up a realm
9 realm is an administrative domain containing any number of Kerberos
10 principals and namespaces. The name of a Kerberos realm is
11 usually a domain name in uppercase. Call your realm the same
12 as your site's domain name if you do not have strong reasons for not
13 doing so. It will make life easier for you and everyone else.
16 * Configuration file::
17 * Creating the database::
18 * Modifying the database::
19 * Using namespaces and synthetic principals to keep the database small::
20 * Using hard aliases for realm migration::
21 * Using soft aliases for configuring referrals::
22 * Checking the setup::
24 * Remote administration::
26 * Testing clients and servers::
28 * Incremental propagation::
29 * Encryption types and salting::
30 * Credential cache server - KCM::
34 * Using LDAP to store the database::
35 * Providing Kerberos credentials to servers and programs::
36 * Setting up PK-INIT::
37 * Debugging Kerberos problems::
40 @node Configuration file, Creating the database, Setting up a realm, Setting up a realm
41 @section Configuration file
43 To setup a realm you will first have to create a configuration file:
44 @file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many
45 configuration options, some of which are described here.
47 There is a sample @file{krb5.conf} supplied with the distribution, and
48 a page for it in section 5 of the system manual.
50 The configuration file is a hierarchical structure consisting of
51 sections, each containing a list of bindings (either variable
52 assignments or subsections). A section starts with
53 @samp{[@samp{section-name}]}. A binding consists of a left hand side, an equal sign
54 (@samp{=}) and a right hand side (the left hand side tag must be
55 separated from the equal sign with some whitespace). Subsections have a
56 @samp{@{} as the first non-whitespace character after the equal sign. All
57 other bindings are treated as variable assignments. The value of a
58 variable extends to the end of the line.
60 Configuration files can also include other files, or all files in a
61 directory. Use absolute paths in include directives. When including a
62 directoty, only files whose names consist of alphanumeric, hyphen, or
63 underscore characters are allowed, though they may end in '.conf'.
66 include /some/config/file
67 includedir /some/config/directory
71 other-var = value with @{@}
76 var = some other value
78 var = yet another value
81 In this manual, names of sections and bindings will be given as strings
82 separated by slashes (@samp{/}). The @samp{other-var} variable will thus
83 be @samp{section1/a-subsection/other-var}.
85 For in-depth information about the contents of the configuration file, refer to
86 the @file{krb5.conf} manual page. Some of the more important sections
87 are briefly described here.
89 The @samp{libdefaults} section contains a list of library configuration
90 parameters, such as the default realm and the timeout for KDC
91 responses. The @samp{realms} section contains information about specific
92 realms, such as where they hide their KDC@.
93 Finally the @samp{domain_realm} section contains a list of
94 mappings from domains to realms.
96 To continue with the realm setup, you will have to create a configuration file,
97 with contents similar to the following.
101 default_realm = MY.REALM
104 kdc = my.kdc my.slave.kdc
107 kdc = [2001:6b0:1:ea::100]:88
110 .my.domain = MY.REALM
114 When realm names correspond to domain names, one can avoid having to
115 configure @samp{domain_realm} mappings, and one can avoid having to
116 configure a @samp{default_realm} in the @samp{libdefaults} section.
117 DNS SRV resource records can be used for KDC discovery, obviating the
118 need list KDCs in the @samp{realms} section of the @samp{krb5.conf}
122 The Heimdal libraries and commands (and the MIT ones too), support the
123 use of the environment variable @samp{KRB5_CONFIG} for using an
124 alternative configuration.
127 env KRB5_CONFIG=$HOME/etc/krb5.conf kinit user@@REALM
131 The Heimdal libraries and commands (and the MIT ones too), support the
132 use of the environment variable @samp{KRB5CCNAME} for specifying a
133 credentials cache to use. See the @manpage{kinit,1} for details.
136 The Heimdal libraries and commands (and the MIT ones too), support the
137 use of the environment variable @samp{KRB5_KTNAME} for specifying a
138 keytab file to use for server operations. See the @manpage{kinit,1} for
141 @cindex KRB5_CLIENT_KTNAME
142 The Heimdal libraries and commands (and the MIT ones too), support the
143 use of the environment variable @samp{KRB5_CLIENT_KTNAME} for specifying
144 a keytab file to use for client operations. See the @manpage{kinit,1}
147 @cindex GSS_MECH_CONFIG
148 The GSS-API mechanism configuration file can also be changed from the
149 default with the enviornment variable @samp{GSS_MECH_CONFIG}. Note that
150 this file can only configure additional plugin mechanisms: Kerberos,
151 NTLM and SPNEGO are built in to the Heimdal GSS-API library.
153 @node Creating the database, Modifying the database, Configuration file, Setting up a realm
154 @section Creating the database
156 The Heimdal database library, @code{libhdb}, will look for the
157 database in the directory @file{@value{dbdir}}, so you should probably
158 create that directory. Make sure the directory has restrictive
163 # chmod og-rwx /var/heimdal
166 Heimdal supports various database backends: lmdb (LMDB), db3 (Berkeley
167 DB 3.x, 4.x, or 5.x), db1 (Berkeley DB 2.x), sqlite (SQLite3), and ldap
168 (LDAP). The default is @value{dbtype}, and is selected at configure
169 time from one of lmdb, db3, or db1.
171 These defaults can be overriden in the 'database' key in the @samp{kdc}
172 section of the configuration.
177 dbname = lmdb:/path/to/db-file
179 acl_file = /path/to/kadmind.acl
180 mkey_file = /path/to/mkey
181 log_file = /path/to/iprop-log-file
185 To use LDAP, see @xref{Using LDAP to store the database}.
187 The keys of all the principals are stored in the database. If you
188 choose to, these can be encrypted with a master key. You do not have to
189 remember this key (or password), but just to enter it once and it will
190 be stored in a file (@file{/var/heimdal/m-key}). If you want to have a
191 master key, run @samp{kstash} to create this master key:
196 Verifying password - Master key:
199 If you want to generate a random master key you can use the
200 @kbd{--random-key} flag to kstash. This will make sure you have a good key
201 on which attackers can't do a dictionary attack.
203 If you have a master key, make sure you make a backup of your master
204 key file; without it backups of the database are of no use.
206 Note that encryption of the keys in the database is only useful when
207 the database is stored on external storage media that is easy to
208 steal. Thus for the most part there is no need to encrypt the keys in
211 To initialise the database use the @command{kadmin} program, with the
212 @kbd{-l} option (to enable local database mode). First issue a
213 @kbd{init MY.REALM} command. This will create the database and insert
214 default principals for that realm. You can have more than one realm in
215 one database, so @samp{init} does not destroy any old database.
217 Before creating the database, @samp{init} will ask you some questions
218 about maximum ticket lifetimes.
220 After creating the database you should probably add yourself to it. You
221 do this with the @samp{add} command. It takes as argument the name of a
222 principal. The principal should contain a realm, so if you haven't set up
223 a default realm, you will need to explicitly include the realm.
227 kadmin> init MY.REALM
228 Realm max ticket life [unlimited]:
229 Realm max renewable ticket life [unlimited]:
231 Max ticket life [unlimited]:
232 Max renewable life [unlimited]:
235 Verifying password - Password:
238 Now start the KDC and try getting a ticket.
243 me@@MY.REALMS's Password:
245 Credentials cache: /tmp/krb5cc_0
246 Principal: me@@MY.REALM
248 Issued Expires Principal
249 Aug 25 07:25:55 Aug 25 17:25:55 krbtgt/MY.REALM@@MY.REALM
252 If you are curious you can use the @samp{dump} command to list all the
253 entries in the database. It should look something similar to the
254 following example (note that the entries here are truncated for
255 typographical reasons):
259 me@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ...
260 kadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ...
261 krbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ...
262 kadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ...
265 @node Modifying the database, Using namespaces and synthetic principals to keep the database small, Creating the database, Setting up a realm
266 @section Modifying the database
268 All modifications of principals are done with with kadmin.
270 A principal has several attributes and lifetimes associated with it.
272 Principals are added, renamed, modified, and deleted with the kadmin
273 commands @samp{add}, @samp{rename}, @samp{modify}, @samp{delete}.
274 Both interactive editing and command line flags can be used (use --help
275 to list the available options).
277 There are different kinds of types for the fields in the database;
278 attributes, absolute time times and relative times.
280 @subsection Attributes
282 When doing interactive editing, attributes are listed with @samp{?}.
284 The attributes are given in a comma (@samp{,}) separated list.
285 Attributes are removed from the list by prefixing them with @samp{-}.
289 Max ticket life [1 day]:
290 Max renewable life [1 week]:
291 Principal expiration time [never]:
292 Password expiration time [never]:
293 Attributes [disallow-renewable]: requires-pre-auth,-disallow-renewable
295 Principal: me@@MY.REALM
297 Attributes: requires-pre-auth
300 @subsection Absolute times
302 The format for absolute times are any of the following:
312 @subsection Relative times
314 The format for relative times are any of the following combined:
325 @c Describe more of kadmin commands here...
327 @node Using namespaces and synthetic principals to keep the database small, Checking the setup, Modifying the database, Setting up a realm
328 @section Using namespaces and synthetic principals to keep the database small
330 Keeping a Kerberos database small is useful for several reasons:
333 @item to avoid low write transaction rates
334 @item to avoid replication latency
335 @item to keep re-keying costs down
338 To avoid needing database entries for client principals, configure and
339 enable PKINIT and synthetic principals. Alternatively, configure and
340 enable the use of GSS-API pre-authentication, though this is currently
343 With synthetic client principals enabled, client principals will be
344 deemed to exist if they can pre-authenticate using a method that
345 yields an authenticated principal name, and if the client principal
346 does not already exist.
348 To lock out or disable a specific synthetic client principal, create
349 it in the database with the desired attributes.
351 To avoid needing database entries for host-based service principals,
352 create virtual host-based service principal namespaces using the
353 @command{add_ns} sub-command of the @command{kadmin} command. Virtual
354 host-based service principals will exist for every possible hostname
355 under a containing namespace, with keys derived from the namespace's
356 based keys and the current key rotation period. The long-term keys of
357 virtual host-based service principals rotate on a hard schedule as
358 configured for their namespaces, so hosts and applications using them
359 must keep re-fetching their @samp{keytabs}. See the manual pages for
360 @file{krb5.conf}, @command{kadmin}, and @command{httpkadmind} for more
363 Using these features one can end up with a database that contains just
364 @code{krbtgt} principals, principals for locked users, and principals
365 that are neither @code{krbtgt}, user, nor host-based services.
367 @node Using hard aliases for realm migration, Using soft aliases for configuring referrals, Using namespaces and synthetic principals to keep the database small, Setting up a realm
368 @section Using hard aliases for realm migration
370 The Heimdal @command{kadmin} command can be used to add aliases to
371 principal entries in the Heimdal database. Aliases of principals of
372 the form @samp{WELLKNOWN/REFERRALS/TARGET} or
373 @samp{WELLKNOWN/REFERRALS/TARGET/anything} are "soft" aliases.
374 Aliases of principals of other forms are "hard" aliases.
376 When a client makes a request for a principal's alias, and it does not
377 use the KDC request "canonicalize" option flag, the Heimdal KDC will
378 treat the alias as a distinct principal that happens to share
379 attributes and long-term symmetric keys and salts with the principal
382 This is useful for, for example, ensuring that host-based principals
383 can be referred to by any aliases.
385 This can also be very useful for renaming realms: add new
386 @code{krbtgt} principals for the new realms, then add aliases to
387 existing principals in their new realms. For example, a user with a
388 principal @code{joe@@A} can be given an alias of
390 then they can @code{kinit joes@@B} and get Kerberos tickets for
391 @code{joes@@B}. Similarly, a service principal such as
392 @code{HTTP/foo.bar.baz.example@@BAZ.EXAMPLE} can be given an alias such as
393 @code{HTTP/foo.bar.baz.example@@BAR.BAZ.EXAMPLE}, or even
394 @code{HTTP/foobar.new-domain.example@@NEW-DOMAIN.EXAMPLE}, and
395 requesting tickets with those aliases as the service names will work.
397 @node Using soft aliases for configuring referrals, Checking the setup, Using hard aliases for realm migration, Setting up a realm
398 @section Using soft aliases for configuring referrals
400 Soft aliases, which are aliases of principals of the form
401 @code{WELLKNOWN/REFERRALS/TARGET} or
402 @code{WELLKNOWN/REFERRALS/TARGET/anything}, are used to generate
403 referrals to other realms. Specifically, the realm of a soft alias'
404 canonical name is the realm to issue referrals to.
406 Soft aliases can be used to configure individual referrals, but also
407 of entire namespaces of hostnames. To configure the issuance of
408 referrals for entire namespaces, make a soft alias of the form
409 @code{WELLKNOWN/HOSTBASED-NAMESPACE/service/namespace-fqdn@@REALM} to
410 have the TGS for that @samp{REALM} issue referrals for all principals
411 of the form @code{service/hostname@@REALM} where the hostname component
412 is a sub-domain of the namespace component of the alias name.
414 For example, a soft alias name
415 @code{WELLKNOWN/HOSTBASED-NAMESPACE/host/cloud.bar.example@@BAR.EXAMPLE}
416 to a realm @samp{B} will cause the KDC to issue referrals to @samp{B}
417 for any principals such as
418 @samp{host/foo.cloud.bar.example@@BAR.EXAMPLE}, and
419 @samp{host/baz.cloud.bar.example@@BAR.EXAMPLE}, and so on.
421 @node Checking the setup, keytabs, Using namespaces and synthetic principals to keep the database small, Setting up a realm
422 @section Checking the setup
424 There are two tools that can check the consistency of the Kerberos
425 configuration file and the Kerberos database.
427 The Kerberos configuration file is checked using
428 @command{verify_krb5_conf}. The tool checks for common errors, but
429 commonly there are several uncommon configuration entries that are
430 never added to the tool and thus generates ``unknown entry'' warnings.
431 This is usually nothing to worry about.
433 The database check is built into the kadmin tool. It will check for
434 common configuration error that will cause problems later. Common
435 check are for existence and flags on important principals. The
436 database check by run by the following command :
439 kadmin -l check REALM.EXAMPLE.ORG
442 @node keytabs, Remote administration, Checking the setup, Setting up a realm
445 To extract a service ticket from the database and put it in a keytab, you
446 need to first create the principal in the database with @samp{add}
447 (using the @kbd{--random-key} flag to get a random key) and then
448 extract it with @samp{ext_keytab}.
451 kadmin> add --random-key host/my.host.name
452 Max ticket life [unlimited]:
453 Max renewable life [unlimited]:
455 kadmin> ext host/my.host.name
458 Version Type Principal
459 1 des-cbc-md5 host/my.host.name@@MY.REALM
460 1 des-cbc-md4 host/my.host.name@@MY.REALM
461 1 des-cbc-crc host/my.host.name@@MY.REALM
462 1 des3-cbc-sha1 host/my.host.name@@MY.REALM
465 @node Remote administration, Password changing, keytabs, Setting up a realm
466 @section Remote administration
468 The administration server, @command{kadmind}, can be started by
469 @command{inetd} (which isn't recommended) or run as a normal daemon. If you
470 want to start it from @command{inetd} you should add a line similar to the
471 one below to your @file{/etc/inetd.conf}.
474 kerberos-adm stream tcp nowait root /usr/heimdal/libexec/kadmind kadmind
477 You might need to add @samp{kerberos-adm} to your @file{/etc/services}
480 Access to the administration server is controlled by an ACL file,
481 (default @file{/var/heimdal/kadmind.acl}.) The file has the following
484 principal [priv1,priv2,...] [glob-pattern]
487 The matching is from top to bottom for matching principals (and if given,
488 glob-pattern). When there is a match, the access rights of that line are
491 The privileges you can assign to a principal are: @samp{add},
492 @samp{change-password} (or @samp{cpw} for short), @samp{delete},
493 @samp{get}, @samp{list}, and @samp{modify}, or the special privilege
494 @samp{all}. All of these roughly correspond to the different commands
497 If a @var{glob-pattern} is given on a line, it restricts the access
498 rights for the principal to only apply for subjects that match the
499 pattern. The patterns are of the same type as those used in shell
500 globbing, see @url{none,,fnmatch(3)}.
502 In the example below @samp{lha/admin} can change every principal in the
503 database. @samp{jimmy/admin} can only modify principals that belong to
504 the realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the
505 help desk, so he should only be able to change the passwords for single
506 component principals (ordinary users). He will not be able to change any
507 @samp{/admin} principal.
510 lha/admin@@E.KTH.SE all
511 jimmy/admin@@E.KTH.SE all *@@E.KTH.SE
512 jimmy/admin@@E.KTH.SE all */*@@E.KTH.SE
513 mille/admin@@E.KTH.SE change-password *@@E.KTH.SE
516 @node Password changing, Testing clients and servers, Remote administration, Setting up a realm
517 @section Password changing
519 To allow users to change their passwords, you should run @command{kpasswdd}.
520 It is not run from @command{inetd}.
522 You might need to add @samp{kpasswd} to your @file{/etc/services} as
523 @samp{464/udp}. If your realm is not setup to use DNS, you might also
524 need to add a @samp{kpasswd_server} entry to the realm configuration
525 in @file{/etc/krb5.conf} on client machines:
530 kdc = my.kdc my.slave.kdc
531 kpasswd_server = my.kdc
535 @subsection Password quality assurance
537 It is important that users have good passwords, both to make it harder
538 to guess them and to avoid off-line attacks (although
539 pre-authentication provides some defence against off-line attacks).
540 To ensure that the users choose good passwords, you can enable
541 password quality controls in @command{kpasswdd} and @command{kadmind}.
542 The controls themselves are done in a shared library or an external
543 program that is used by @command{kpasswdd}. To configure in these
544 controls, add lines similar to the following to your
545 @file{/etc/krb5.conf}:
549 policies = external-check builtin:minimum-length modulename:policyname
550 external_program = /bin/false
551 policy_libraries = @var{library1.so} @var{library2.so}
554 In @samp{[password_quality]policies} the module name is optional if
555 the policy name is unique in all modules (members of
556 @samp{policy_libraries}). All built-in policies can be qualified with
557 a module name of @samp{builtin} to unambiguously specify the built-in
558 policy and not a policy by the same name from a loaded module.
560 The built-in policies are
566 Executes the program specified by @samp{[password_quality]external_program}.
568 A number of key/value pairs are passed as input to the program, one per
569 line, ending with the string @samp{end}. The key/value lines are of
572 principal: @var{principal}
573 new-password: @var{password}
575 where @var{password} is the password to check for the previous
578 If the external application approves the password, it should return
579 @samp{APPROVED} on standard out and exit with exit code 0. If it
580 doesn't approve the password, an one line error message explaining the
581 problem should be returned on standard error and the application
582 should exit with exit code 0. In case of a fatal error, the
583 application should, if possible, print an error message on standard
584 error and exit with a non-zero error code.
588 The minimum length password quality check reads the configuration file
589 stanza @samp{[password_quality]min_length} and requires the password
590 to be at least this length.
592 @item character-class
594 The character-class password quality check reads the configuration
595 file stanza @samp{[password_quality]min_classes}. The policy requires
596 the password to have characters from at least that many character
597 classes. Default value if not given is 3.
599 The four different characters classes are, uppercase, lowercase,
600 number, special characters.
602 @item enforce_on_admin_set
604 The enforce_on_admin_set check subjects administrative password updates to the
605 password policy. An administrative password update is a create principal or
606 change password request via @command{kadmind}, or a set password request via
607 @command{kpasswdd}. (A set password request is one where the authenticating
608 principal differs from the principal whose password is being changed.) Password
609 policies are always ignored if the authenticating principal is the kadmin
610 service itself, for example when running @command{kadmin} in local mode. The
611 default value for enforce_on_admin_set if not given is true.
615 If you want to write your own shared object to check password
616 policies, see the manual page @manpage{kadm5_pwcheck,3}.
618 Code for a password quality checking function that uses the cracklib
619 library can be found in @file{lib/kadm5/sample_password_check.c} in
620 the source code distribution. It requires that the cracklib library
621 be built with the patch available at
622 @url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}.
624 A sample policy external program is included in
625 @file{lib/kadm5/check-cracklib.pl}.
627 If no password quality checking function is configured, the only check
628 performed is that the password is at least six characters long.
630 To check the password policy settings, use the command
631 @command{verify-password-quality} in @command{kadmin} program. The password
632 verification is only performed locally, on the client. It may be
633 convenient to set the environment variable @samp{KRB5_CONFIG} to point
634 to a test version of @file{krb5.conf} while you're testing the
635 @samp{[password_quality]} stanza that way.
637 @node Testing clients and servers, Slave Servers, Password changing, Setting up a realm
638 @section Testing clients and servers
640 Now you should be able to run all the clients and servers. Refer to the
641 appropriate man pages for information on how to use them.
643 @node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm
644 @section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm
646 It is desirable to have at least one backup (slave) server in case the
647 master server fails. It is possible to have any number of such slave
648 servers but more than three usually doesn't buy much more redundancy.
650 All Kerberos servers for a realm must have the same database so that
651 they present the same service to the users. The
653 @command{hprop} program, running on the master, will propagate the database
654 to the slaves, running
656 @command{hpropd} processes.
658 Every slave needs a database directory, the master key (if it was used
659 for the database) and a keytab with the principal
660 @samp{hprop/@var{hostname}}. Add the principal with the
662 @command{ktutil} command and start
664 @command{hpropd}, as follows:
667 slave# ktutil get -p foo/admin hprop/`hostname`
668 slave# mkdir /var/heimdal
672 The master will use the principal @samp{kadmin/hprop} to authenticate to
673 the slaves. This principal should be added when running @kbd{kadmin -l
674 init} but if you do not have it in your database for whatever reason,
675 please add it with @kbd{kadmin -l add}.
679 @code{hprop} on the master:
685 This was just an hands-on example to make sure that everything was
686 working properly. Doing it manually is of course the wrong way, and to
687 automate this you will want to start
689 @command{hpropd} from @command{inetd} on the slave(s) and regularly run
691 @command{hprop} on the master to regularly propagate the database.
692 Starting the propagation once an hour from @command{cron} is probably a
695 @node Incremental propagation, Encryption types and salting, Slave Servers, Setting up a realm
696 @section Incremental propagation
698 There is also a newer mechanism for
699 doing incremental propagation in Heimdal. Instead of sending the whole
700 database regularly, it sends the changes as they happen on the master to
701 the slaves. The master keeps track of all the changes by assigning a
702 version number to every change to the database. The slaves know which
703 was the latest version they saw and in this way it can be determined if
704 they are in sync or not. A log of all the changes is kept on the master,
705 and when a slave is at an older version than the oldest one in the
706 log, the whole database has to be sent.
708 Protocol-wise, all the slaves connect to the master and as a greeting
709 tell it the latest version that they have (@samp{IHAVE} message). The
710 master then responds by sending all the changes between that version and
711 the current version at the master (a series of @samp{FORYOU} messages)
712 or the whole database in a @samp{TELLYOUEVERYTHING} message. There is
713 also a keep-alive protocol that makes sure all slaves are up and running.
715 In addition on listening on the network to get connection from new
716 slaves, the ipropd-master also listens on a status unix
717 socket. kadmind and kpasswdd both open that socket when a transation
718 is done and written a notification to the socket. That cause
719 ipropd-master to check for new version in the log file. As a fallback in
720 case a notification is lost by the unix socket, the log file is
721 checked after 30 seconds of no event.
723 @subsection Configuring incremental propagation
725 The program that runs on the master is @command{ipropd-master} and all
726 clients run @command{ipropd-slave}.
728 Create the file @file{/var/heimdal/slaves} on the master containing all
729 the slaves that the database should be propagated to. Each line contains
730 the full name of the principal (for example
731 @samp{iprop/hemligare.foo.se@@FOO.SE}).
733 You should already have @samp{iprop/tcp} defined as 2121, in your
734 @file{/etc/services}. Otherwise, or if you need to use a different port
735 for some peculiar reason, you can use the @kbd{--port} option. This is
736 useful when you have multiple realms to distribute from one server.
738 Then you need to create those principals that you added in the
739 configuration file. Create one @samp{iprop/hostname} for the master and
744 master# /usr/heimdal/sbin/ktutil get iprop/`hostname`
748 slave# /usr/heimdal/sbin/ktutil get iprop/`hostname`
752 The next step is to start the @command{ipropd-master} process on the master
753 server. The @command{ipropd-master} listens on the UNIX domain socket
754 @file{/var/heimdal/signal} to know when changes have been made to the
755 database so they can be propagated to the slaves. There is also a
756 safety feature of testing the version number regularly (every 30
757 seconds) to see if it has been modified by some means that do not raise
758 this signal. Then, start @command{ipropd-slave} on all the slaves:
761 master# /usr/heimdal/libexec/ipropd-master &
762 slave# /usr/heimdal/libexec/ipropd-slave master &
765 To manage the iprop log file you should use the @command{iprop-log}
766 command. With it you can dump, truncate and replay the logfile.
768 @subsection Status of iprop master and slave
770 Both the master and slave provides status of the world as they see it.
772 The master write outs the current status of the slaves, last seen and
773 their version number in @file{/var/heimdal/slaves-stats}.
775 The slave write out the current status in @file{/var/heimdal/ipropd-slave-status}.
777 These locations can be changed with command line options, and in the
778 case of @command{ipropd_master}, the configuration file.
780 @node Encryption types and salting, Credential cache server - KCM, Incremental propagation, Setting up a realm
781 @section Encryption types and salting
783 @cindex Encryption types
785 The encryption types that the KDC is going to assign by default is
786 possible to change. Since the keys used for user authentication is
787 salted the encryption types are described together with the salt
790 Salting is used to make it harder to pre-calculate all possible
791 keys. Using a salt increases the search space to make it almost
792 impossible to pre-calculate all keys. Salting is the process of mixing a
793 public string (the salt) with the password, then sending it through an
794 encryption type specific string-to-key function that will output the
795 fixed size encryption key.
797 In Kerberos 5 the salt is determined by the encryption type, except in
800 In @code{arcfour} (the encryption type that Microsoft Windows 2000 uses)
801 there is no salt. This is to be compatible with NTLM keys in Windows
804 @code{[kadmin]default_keys} in @file{krb5.conf} controls
807 The syntax of @code{[kadmin]default_keys} is
808 @samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption
809 type (des-cbc-crc, arcfour-hmac-md5, aes256-cts-hmac-sha1-96),
810 @code{salt-type} is the type of salt (pw-salt or afs3-salt), and the
811 salt-string is the string that will be used as salt (remember that if
812 the salt is appended/prepended, the empty salt "" is the same thing as
815 Common types of salting include
818 @item @code{v5} (or @code{pw-salt})
820 @code{pw-salt} uses the default salt for each encryption type is
821 specified for. If the encryption type @samp{etype} isn't given, all
822 default encryption will be used.
824 @item @code{afs3-salt}
826 @code{afs3-salt} is the salt that is used with Transarc kaserver. It's
827 the cell name appended to the password.
831 @node Credential cache server - KCM, Cross realm, Encryption types and salting, Setting up a realm
832 @section Credential cache server - KCM
834 @cindex Credential cache server
836 When KCM running is easy for users to switch between different
837 kerberos principals using @file{kswitch} or built in support in
838 application, like OpenSSH's GSSAPIClientIdentity.
840 Other advantages are that there is the long term credentials are not
841 written to disk and on reboot the credential is removed when kcm
842 process stopps running.
844 Configure the system startup script to start the kcm process,
845 @file{/usr/heimdal/libexec/kcm} and then configure the system to use kcm in @file{krb5.conf}.
849 default_cc_type = KCM
852 Now when you run @command{kinit} it doesn't overwrite your existing
853 credentials but rather just add them to the set of
854 credentials. @command{klist -l} lists the credentials and the star
855 marks the default credential.
859 lha@@KTH.SE's Password:
861 Name Cache name Expires
862 lha@@KTH.SE 0 Nov 22 23:09:40 *
863 lha@@SU.SE Initial default ccache Nov 22 14:14:24
866 When switching between credentials you can use @command{kswitch}.
876 After switching, a new set of credentials are used as default.
880 Name Cache name Expires
881 lha@@SU.SE Initial default ccache Nov 22 14:14:24 *
882 lha@@KTH.SE 0 Nov 22 23:09:40
885 Som applications, like openssh with Simon Wilkinsons patch applied,
886 support specifiying that credential to use. The example below will
887 login to the host computer.kth.se using lha@@KTH.SE (not the current
892 -o GSSAPIAuthentication=yes \
893 -o GSSAPIKeyExchange=yes \
894 -o GSSAPIClientIdentity=lha@@KTH.SE \
900 @node Cross realm, Transit policy, Credential cache server - KCM, Setting up a realm
904 Suppose you reside in the realm @samp{MY.REALM}, how do you
905 authenticate to a server in @samp{OTHER.REALM}? Having valid tickets in
906 @samp{MY.REALM} allows you to communicate with Kerberised services in that
907 realm. However, the computer in the other realm does not have a secret
908 key shared with the Kerberos server in your realm.
910 It is possible to share keys between two realms that trust each
911 other. When a client program, such as @command{telnet} or @command{ssh},
912 finds that the other computer is in a different realm, it will try to
913 get a ticket granting ticket for that other realm, but from the local
914 Kerberos server. With that ticket granting ticket, it will then obtain
915 service tickets from the Kerberos server in the other realm.
917 For a two way trust between @samp{MY.REALM} and @samp{OTHER.REALM}
918 add the following principals to each realm. The principals should be
919 @samp{krbtgt/OTHER.REALM@@MY.REALM} and
920 @samp{krbtgt/MY.REALM@@OTHER.REALM} in @samp{MY.REALM}, and
921 @samp{krbtgt/MY.REALM@@OTHER.REALM} and
922 @samp{krbtgt/OTHER.REALM@@MY.REALM}in @samp{OTHER.REALM}.
924 In Kerberos 5 the trust can be configured to be one way. So that
925 users from @samp{MY.REALM} can authenticate to services in
926 @samp{OTHER.REALM}, but not the opposite. In the example above, the
927 @samp{krbtgt/MY.REALM@@OTHER.REALM} then should be removed.
929 The two principals must have the same key, key version number, and the
930 same set of encryption types. Remember to transfer the two keys in a
935 Credentials cache: FILE:/tmp/krb5cc_913.console
936 Principal: lha@@E.KTH.SE
938 Issued Expires Principal
939 May 3 13:55:52 May 3 23:55:54 krbtgt/E.KTH.SE@@E.KTH.SE
941 vr$ telnet -l lha hummel.it.su.se
942 Trying 2001:6b0:5:1095:250:fcff:fe24:dbf...
943 Connected to hummel.it.su.se.
944 Escape character is '^]'.
945 Waiting for encryption to be negotiated...
946 [ Trying mutual KERBEROS5 (host/hummel.it.su.se@@SU.SE)... ]
947 [ Kerberos V5 accepts you as ``lha@@E.KTH.SE'' ]
948 Encryption negotiated.
949 Last login: Sat May 3 14:11:47 from vr.l.nxs.se
953 Credentials cache: FILE:/tmp/krb5cc_913.console
954 Principal: lha@@E.KTH.SE
956 Issued Expires Principal
957 May 3 13:55:52 May 3 23:55:54 krbtgt/E.KTH.SE@@E.KTH.SE
958 May 3 13:55:56 May 3 23:55:54 krbtgt/SU.SE@@E.KTH.SE
959 May 3 14:10:54 May 3 23:55:54 host/hummel.it.su.se@@SU.SE
963 @node Transit policy, Setting up DNS, Cross realm, Setting up a realm
964 @section Transit policy
965 @cindex Transit policy
967 Under some circumstances, you may not wish to set up direct
968 cross-realm trust with every realm to which you wish to authenticate
969 or from which you wish to accept authentications. Kerberos supports
970 multi-hop cross-realm trust where a client principal in realm A
971 authenticates to a service in realm C through a realm B with which
972 both A and C have cross-realm trust relationships. In this situation,
973 A and C need not set up cross-realm principals between each other.
975 If you want to use cross-realm authentication through an intermediate
976 realm, it must be explicitly allowed by either the KDCs for the realm
977 to which the client is authenticating (in this case, realm C), or the
978 server receiving the request. This is done in @file{krb5.conf} in the
979 @code{[capaths]} section.
981 In addition, the client in realm A need to be configured to know how
982 to reach realm C via realm B. This can be done either on the client or
983 via KDC configuration in the KDC for realm A.
985 @subsection Allowing cross-realm transits
987 When the ticket transits through a realm to another realm, the
988 destination realm adds its peer to the "transited-realms" field in the
989 ticket. The field is unordered, since there is no way to know if know
990 if one of the transited-realms changed the order of the list. For the
991 authentication to be accepted by the final destination realm, all of
992 the transited realms must be listed as trusted in the @code{[capaths]}
993 configuration, either in the KDC for the destination realm or on the
994 server receiving the authentication.
996 The syntax for @code{[capaths]} section is:
1001 SERVER-REALM = PERMITTED-CROSS-REALMS ...
1005 In the following example, the realm @code{STACKEN.KTH.SE} only has
1006 direct cross-realm set up with @code{KTH.SE}. @code{KTH.SE} has
1007 direct cross-realm set up with @code{STACKEN.KTH.SE} and @code{SU.SE}.
1008 @code{DSV.SU.SE} only has direct cross-realm set up with @code{SU.SE}.
1009 The goal is to allow principals in the @code{DSV.SU.SE} or
1010 @code{SU.SE} realms to authenticate to services in
1011 @code{STACKEN.KTH.SE}. This is done with the following
1012 @code{[capaths]} entry on either the server accepting authentication
1013 or on the KDC for @code{STACKEN.KTH.SE}.
1018 STACKEN.KTH.SE = KTH.SE
1021 STACKEN.KTH.SE = SU.SE KTH.SE
1025 The first entry allows cross-realm authentication from clients in
1026 @code{SU.SE} transiting through @code{KTH.SE} to
1027 @code{STACKEN.KTH.SE}. The second entry allows cross-realm
1028 authentication from clients in @code{DSV.SU.SE} transiting through
1029 both @code{SU.SE} and @code{KTH.SE} to @code{STACKEN.KTH.SE}.
1031 Be careful of which realm goes where; it's easy to put realms in the
1032 wrong place. The block is tagged with the client realm (the realm of
1033 the principal authenticating), and the realm before the equal sign is
1034 the final destination realm: the realm to which the client is
1035 authenticating. After the equal sign go all the realms that the
1036 client transits through.
1038 The order of the @code{PERMITTED-CROSS-REALMS} is not important when
1039 doing transit cross realm verification.
1041 @subsection Configuring client cross-realm transits
1043 The @code{[capaths]} section is also used for another purpose: to tell
1044 clients which realm to transit through to reach a realm with which
1045 their local realm does not have cross-realm trust. This can be done
1046 by either putting a @code{[capaths]} entry in the configuration of the
1047 client or by putting the entry in the configuration of the KDC for the
1048 client's local realm. In the latter case, the KDC will then hand back
1049 a referral to the client when the client requests a cross-realm ticket
1050 to the destination realm, telling the client to try to go through an
1053 For client configuration, the order of @code{PERMITTED-CROSS-REALMS}
1054 is significant, since only the first realm in this section (after the
1055 equal sign) is used by the client.
1057 For example, again consider the @code{[capaths]} entry above for the
1058 case of a client in the @code{SU.SE} realm, and assume that the client
1059 or the @code{SU.SE} KDC has that @code{[capaths]} entry. If the
1060 client attempts to authenticate to a service in the
1061 @code{STACKEN.KTH.SE} realm, that entry says to first authenticate
1062 cross-realm to the @code{KTH.SE} realm (the first realm listed in the
1063 @code{PERMITTED-CROSS-REALMS} section), and then from there to
1064 @code{STACKEN.KTH.SE}.
1066 Each entry in @code{[capaths]} can only give the next hop, since only
1067 the first realm in @code{PERMITTED-CROSS-REALMS} is used. If, for
1068 instance, a client in @code{DSV.SU.SE} had a @code{[capaths]}
1069 configuration as above but without the first block for @code{SU.SE},
1070 they would not be able to reach @code{STACKEN.KTH.SE}. They would get
1071 as far as @code{SU.SE} based on the @code{DSV.SU.SE} entry in
1072 @code{[capaths]} and then attempt to go directly from there to
1073 @code{STACKEN.KTH.SE} and get stuck (unless, of course, the
1074 @code{SU.SE} KDC had the additional entry required to tell the client
1075 to go through @code{KTH.SE}).
1077 @subsection Active Directory forest example
1079 One common place where a @code{[capaths]} configuration is desirable
1080 is with Windows Active Directory forests. One common Active Directory
1081 configuration is to have one top-level Active Directory realm but then
1082 divide systems, services, and users into child realms (perhaps based
1083 on organizational unit). One generally establishes cross-realm trust
1084 only with the top-level realm, and then uses transit policy to permit
1085 authentications to and from the child realms.
1087 For example, suppose an organization has a Heimdal realm
1088 @code{EXAMPLE.COM}, a Windows Active Directory realm
1089 @code{WIN.EXAMPLE.COM}, and then child Active Directory realms
1090 @code{ENGR.WIN.EXAMPLE.COM} and @code{SALES.WIN.EXAMPLE.COM}. The
1091 goal is to allow users in any of these realms to authenticate to
1092 services in any of these realms. The @code{EXAMPLE.COM} KDC (and
1093 possibly client) configuration should therefore contain a
1094 @code{[capaths]} section as follows:
1098 ENGR.WIN.EXAMPLE.COM = @{
1099 EXAMPLE.COM = WIN.EXAMPLE.COM
1101 SALES.WIN.EXAMPLE.COM = @{
1102 EXAMPLE.COM = WIN.EXAMPLE.COM
1105 ENGR.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM
1106 SALES.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM
1110 The first two blocks allow clients in the @code{ENGR.WIN.EXAMPLE.COM}
1111 and @code{SALES.WIN.EXAMPLE.COM} realms to authenticate to services in
1112 the @code{EXAMPLE.COM} realm. The third block tells the client (or
1113 tells the KDC to tell the client via referrals) to transit through
1114 @code{WIN.EXAMPLE.COM} to reach these realms. Both sides of the
1115 configuration are needed for bi-directional transited cross-realm
1118 @c To test the cross realm configuration, use:
1119 @c kmumble transit-check client server transit-realms ...
1121 @node Setting up DNS, Using LDAP to store the database, Transit policy, Setting up a realm
1122 @section Setting up DNS
1123 @cindex Setting up DNS
1125 @subsection Using DNS to find KDC
1127 If there is information about where to find the KDC or kadmind for a
1128 realm in the @file{krb5.conf} for a realm, that information will be
1129 preferred, and DNS will not be queried.
1131 Heimdal will try to use DNS to find the KDCs for a realm. First it
1132 will try to find a @code{SRV} resource record (RR) for the realm. If no
1133 SRV RRs are found, it will fall back to looking for an @code{A} RR for
1134 a machine named kerberos.REALM, and then kerberos-1.REALM, etc
1136 Adding this information to DNS minimises the client configuration (in
1137 the common case, resulting in no configuration needed) and allows the
1138 system administrator to change the number of KDCs and on what machines
1139 they are running without caring about clients.
1141 The downside of using DNS is that the client might be fooled to use the
1142 wrong server if someone fakes DNS replies/data, but storing the IP
1143 addresses of the KDC on all the clients makes it very hard to change
1146 An example of the configuration for the realm @code{EXAMPLE.COM}:
1150 $ORIGIN example.com.
1151 _kerberos._tcp SRV 10 1 88 kerberos.example.com.
1152 _kerberos._udp SRV 10 1 88 kerberos.example.com.
1153 _kerberos._tcp SRV 10 1 88 kerberos-1.example.com.
1154 _kerberos._udp SRV 10 1 88 kerberos-1.example.com.
1155 _kpasswd._udp SRV 10 1 464 kerberos.example.com.
1156 _kerberos-adm._tcp SRV 10 1 749 kerberos.example.com.
1160 More information about DNS SRV resource records can be found in
1161 RFC-2782 (A DNS RR for specifying the location of services (DNS SRV)).
1163 @subsection Using DNS to map hostname to Kerberos realm
1165 Heimdal also supports a way to lookup a realm from a hostname. This to
1166 minimise configuration needed on clients. Using this has the drawback
1167 that clients can be redirected by an attacker to realms within the
1168 same cross realm trust and made to believe they are talking to the
1169 right server (since Kerberos authentication will succeed).
1171 An example configuration that informs clients that for the realms
1172 it.example.com and srv.example.com, they should use the realm
1177 $ORIGIN example.com.
1178 _kerberos.it TXT "EXAMPLE.COM"
1179 _kerberos.srv TXT "EXAMPLE.COM"
1183 @node Using LDAP to store the database, Providing Kerberos credentials to servers and programs, Setting up DNS, Setting up a realm
1184 @section Using LDAP to store the database
1185 @cindex Using the LDAP backend
1187 This document describes how to install the LDAP backend for
1188 Heimdal. Note that before attempting to configure such an
1189 installation, you should be aware of the implications of storing
1190 private information (such as users' keys) in a directory service
1191 primarily designed for public information. Nonetheless, with a
1192 suitable authorisation policy, it is possible to set this up in a
1193 secure fashion. A knowledge of LDAP, Kerberos, and C is necessary to
1194 install this backend. The HDB schema was devised by Leif Johansson.
1196 This assumes, OpenLDAP 2.3 or later.
1203 A current release of Heimdal, configured with
1204 @code{--with-openldap=/usr/local} (adjust according to where you have
1205 installed OpenLDAP).
1207 You can verify that you manage to configure LDAP support by running
1208 @file{kdc --builtin-hdb}, and checking that @samp{ldap:} is one entry
1211 Its also possible to configure the ldap backend as a shared module,
1212 see option --hdb-openldap-module to configure.
1215 Optionally configure OpenLDAP with @kbd{--enable-local} to enable the
1219 Add the hdb schema to the LDAP server, it's included in the source-tree
1220 in @file{lib/hdb/hdb.schema}. Example from slapd.conf:
1223 include /usr/local/etc/openldap/schema/hdb.schema
1227 Configure the LDAP server ACLs to accept writes from clients. For
1232 by dn.exact="uid=heimdal,dc=services,dc=example,dc=com" write
1235 authz-regexp "gidNumber=.*\\\+uidNumber=0,cn=peercred,cn=external,cn=auth''
1236 "uid=heimdal,dc=services,dc=example,dc=com"
1240 The sasl-regexp is for mapping between the SASL/EXTERNAL and a user in
1241 a tree. The user that the key is mapped to should be have a
1242 krb5Principal aux object with krb5PrincipalName set so that the
1243 ``creator'' and ``modifier'' is right in @file{kadmin}.
1245 Another option is to create an admins group and add the dn to that
1248 If a non-local LDAP connection is used, the authz-regexp is not
1249 needed as Heimdal will bind to LDAP over the network using
1250 provided credentials.
1252 Since Heimdal talks to the LDAP server over a UNIX domain socket when
1253 configured for ldapi:///, and uses external sasl authentication, it's
1254 not possible to require security layer quality (ssf in cyrus-sasl lingo).
1255 So that requirement has to be turned off in OpenLDAP @command{slapd}
1260 sasl-secprops minssf=0
1265 Start @command{slapd} with the local listener (as well as the default TCP/IP
1266 listener on port 389) as follows:
1269 slapd -h "ldapi:/// ldap:///"
1272 Note: These is a bug in @command{slapd} where it appears to corrupt the krb5Key
1273 binary attribute on shutdown. This may be related to our use of the V3
1274 schema definition syntax instead of the old UMich-style, V2 syntax.
1277 You should specify the distinguished name under which your
1278 principals will be stored in @file{krb5.conf}. Also you need to
1279 enter the path to the kadmin acl file:
1284 # Optional configuration
1285 hdb-ldap-structural-object = inetOrgPerson
1286 hdb-ldap-url = ldapi:/// (default), ldap://hostname or ldaps://hostname
1287 hdb-ldap-secret-file = /path/to/file/containing/ldap/credentials
1288 hdb-ldap-start-tls = false
1291 dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com
1292 acl_file = /path/to/kadmind.acl
1293 mkey_file = /path/to/mkey
1297 @samp{mkey_file} can be excluded if you feel that you trust your ldap
1298 directory to have the raw keys inside it. The
1299 hdb-ldap-structural-object is not necessary if you do not need Samba
1302 If connecting to a server over a non-local transport, the @samp{hdb-ldap-url}
1303 and @samp{hdb-ldap-secret-file} options must be provided. The
1304 @samp{hdb-ldap-secret-file} must contain the bind credentials:
1308 hdb-ldap-bind-dn = uid=heimdal,dc=services,dc=example,dc=com
1309 hdb-ldap-bind-password = secretBindPassword
1312 The @samp{hdb-ldap-secret-file} and should be protected with appropriate
1316 Once you have built Heimdal and started the LDAP server, run kadmin
1317 (as usual) to initialise the database. Note that the instructions for
1318 stashing a master key are as per any Heimdal installation.
1322 kadmin> init EXAMPLE.COM
1323 Realm max ticket life [unlimited]:
1324 Realm max renewable ticket life [unlimited]:
1326 Max ticket life [1 day]:
1327 Max renewable life [1 week]:
1328 Principal expiration time [never]:
1329 Password expiration time [never]:
1331 lukeh@@EXAMPLE.COM's Password:
1332 Verifying password - lukeh@@EXAMPLE.COM's Password:
1336 Verify that the principal database has indeed been stored in the
1337 directory with the following command:
1340 kdc# ldapsearch -L -h localhost -D cn=manager \
1341 -w secret -b ou=KerberosPrincipals,dc=example,dc=com \
1342 'objectclass=krb5KDCEntry'
1346 Now consider adding indexes to the database to speed up the access, at
1347 least theses should be added to slapd.conf.
1350 index objectClass eq
1351 index cn eq,sub,pres
1352 index uid eq,sub,pres
1353 index displayName eq,sub,pres
1354 index krb5PrincipalName eq
1359 @subsection smbk5pwd overlay
1361 The smbk5pwd overlay, updates the krb5Key and krb5KeyVersionNumber
1362 appropriately when it receives an LDAP Password change Extended
1365 @url{http://www.openldap.org/devel/cvsweb.cgi/contrib/slapd-modules/smbk5pwd/README?hideattic=1&sortbydate=0}
1367 @subsection Troubleshooting guide
1369 @url{https://sec.miljovern.no/bin/view/Info/TroubleshootingGuide}
1372 @subsection Using Samba LDAP password database
1375 @c @node Using Samba LDAP password database, Providing Kerberos credentials to servers and programs, Using LDAP to store the database, Setting up a realm
1376 @c @section Using Samba LDAP password database
1378 The Samba domain and the Kerberos realm can have different names since
1379 arcfour's string to key functions principal/realm independent. So now
1380 will be your first and only chance name your Kerberos realm without
1381 needing to deal with old configuration files.
1383 First, you should set up Samba and get that working with LDAP backend.
1385 Now you can proceed as in @xref{Using LDAP to store the database}.
1386 Heimdal will pick up the Samba LDAP entries if they are in the same
1387 search space as the Kerberos entries.
1389 @node Providing Kerberos credentials to servers and programs, Setting up PK-INIT, Using LDAP to store the database, Setting up a realm
1390 @section Providing Kerberos credentials to servers and programs
1392 Some services require Kerberos credentials when they start to make
1393 connections to other services or need to use them when they have started.
1395 The easiest way to get tickets for a service is to store the key in a
1396 keytab. Both ktutil get and kadmin ext can be used to get a
1397 keytab. ktutil get is better in that way it changes the key/password
1398 for the user. This is also the problem with ktutil. If ktutil is used
1399 for the same service principal on several hosts, they keytab will only
1400 be useful on the last host. In that case, run the extract command on
1401 one host and then securely copy the keytab around to all other hosts
1405 host# ktutil -k /etc/krb5-service.keytab \
1406 get -p lha/admin@@EXAMPLE.ORG service-principal@@EXAMPLE.ORG
1407 lha/admin@@EXAMPLE.ORG's Password:
1410 To get a Kerberos credential file for the service, use kinit in the
1411 @kbd{--keytab} mode. This will not ask for a password but instead fetch the
1412 key from the keytab.
1415 service@@host$ kinit --cache=/var/run/service_krb5_cache \
1416 --keytab=/etc/krb5-service.keytab \
1417 service-principal@@EXAMPLE.ORG
1420 Long running services might need credentials longer then the
1421 expiration time of the tickets. kinit can run in a mode that refreshes
1422 the tickets before they expire. This is useful for services that write
1423 into AFS and other distributed file systems using Kerberos. To run the
1424 long running script, just append the program and arguments (if any)
1425 after the principal. kinit will stop refreshing credentials and remove
1426 the credentials when the script-to-start-service exits.
1429 service@@host$ kinit --cache=/var/run/service_krb5_cache \
1430 --keytab=/etc/krb5-service.keytab \
1431 service-principal@@EXAMPLE.ORG \
1432 script-to-start-service argument1 argument2
1436 @node Setting up PK-INIT, Debugging Kerberos problems, Providing Kerberos credentials to servers and programs, Setting up a realm
1437 @section Setting up PK-INIT
1439 PK-INIT leverages an existing PKI (public key infrastructure), using
1440 certificates to get the initial ticket (usually the krbtgt
1441 ticket-granting ticket).
1443 To use PK-INIT you must first have a PKI. If you don't have one, it is
1444 time to create it. You should first read the whole current chapter of
1445 the document to see the requirements imposed on the CA software.
1447 A mapping between the PKI certificate and what principals that
1448 certificate is allowed to use must exist. There are several ways to do
1449 this. The administrator can use a configuration file, store the
1450 principal in the SubjectAltName extension of the certificate, or store
1451 the mapping in the principals entry in the kerberos database.
1453 @section Certificates
1455 This and following subsection documents the requirements on the KDC
1456 and client certificates and the format used in the id-pkinit-san
1457 OtherName extension.
1459 On how to create certificates, you should read @ref{Use OpenSSL to
1460 create certificates}.
1462 @subsection KDC certificate
1464 The certificate for the KDC has several requirements.
1466 First, the certificate should have an Extended Key Usage (EKU)
1467 id-pkkdcekuoid (1.3.6.1.5.2.3.5) set. Second, there must be a
1468 subjectAltName otherName using OID id-pkinit-san (1.3.6.1.5.2.2) in
1469 the type field and a DER encoded KRB5PrincipalName that matches the
1470 name of the TGS of the target realm. Also, if the certificate has a
1471 nameConstraints extension with a Generalname with dNSName or iPAddress,
1472 it must match the hostname or address of the KDC.
1474 The client is not required by the standard to check the server
1475 certificate for this information if the client has external
1476 information confirming which certificate the KDC is supposed to be
1477 using. However, adding this information to the KDC certificate removes
1478 the need to specially configure the client to recognize the KDC
1481 Remember that if the client would accept any certificate as the KDC's
1482 certificate, the client could be fooled into trusting something that
1483 isn't a KDC and thus expose the user to giving away information (like
1484 a password or other private information) that it is supposed to keep
1487 @subsection Client certificate
1489 The client certificate may need to have a EKU id-pkekuoid
1490 (1.3.6.1.5.2.3.4) set depending on the configuration on the KDC.
1492 It possible to store the principal (if allowed by the KDC) in the
1493 certificate and thus delegate responsibility to do the mapping between
1494 certificates and principals to the CA.
1496 This behavior is controlled by KDC configuration option:
1500 pkinit_principal_in_certificate = yes
1503 @subsubsection Using KRB5PrincipalName in id-pkinit-san
1505 The OtherName extension in the GeneralName is used to do the mapping
1506 between certificate and principal. For the KDC certificate, this
1507 stores the krbtgt principal name for that KDC. For the client
1508 certificate, this stores the principal for which that certificate is
1509 allowed to get tickets.
1511 The principal is stored in a SubjectAltName in the certificate using
1512 OtherName. The OID in the type is id-pkinit-san.
1515 id-pkinit-san OBJECT IDENTIFIER ::= @{ iso (1) org (3) dod (6)
1516 internet (1) security (5) kerberosv5 (2) 2 @}
1519 The data part of the OtherName is filled with the following DER
1520 encoded ASN.1 structure:
1523 KRB5PrincipalName ::= SEQUENCE @{
1525 principalName [1] PrincipalName
1529 where Realm and PrincipalName is defined by the Kerberos ASN.1
1532 @section Naming certificate using hx509
1534 hx509 is the X.509 software used in Heimdal to handle
1535 certificates. hx509 supports several different syntaxes for specifying
1536 certificate files or formats. Several formats may be used: PEM,
1537 certificates embedded in PKCS#12 files, certificates embedded in
1538 PKCS#11 devices, and raw DER encoded certificates.
1540 Those formats may be specified as follows:
1546 DIR specifies a directory which contains certificates in the DER or
1549 The main feature of DIR is that the directory is read on demand when
1550 iterating over certificates. This allows applications, in some
1551 situations, to avoid having to store all certificates in memory. It's
1552 very useful for tests that iterate over large numbers of certificates.
1557 DIR:/path/to/der/files
1562 FILE: specifies a file that contains a certificate or private key.
1563 The file can be either a PEM (openssl) file or a raw DER encoded
1564 certificate. If it's a PEM file, it can contain several keys and
1565 certificates and the code will try to match the private key and
1566 certificate together. Multiple files may be specified, separated by
1569 It's useful to have one PEM file that contains all the trust anchors.
1574 FILE:certificate.pem,private-key.key,other-cert.pem,....
1579 PKCS11: is used to handle smartcards via PKCS#11 drivers, such as
1580 soft-token, opensc, or muscle. The argument specifies a shared object
1581 that implements the PKCS#11 API. The default is to use all slots on
1587 PKCS11:shared-object.so
1592 PKCS12: is used to handle PKCS#12 files. PKCS#12 files commonly have
1593 the extension pfx or p12.
1598 PKCS12:/path/to/file.pfx
1603 @section Configure the Kerberos software
1605 First configure the client's trust anchors and what parameters to
1606 verify. See the subsections below for how to do that. Then, you can
1607 use kinit to get yourself tickets. For example:
1610 $ kinit -C FILE:$HOME/.certs/lha.crt,$HOME/.certs/lha.key lha@@EXAMPLE.ORG
1611 Enter your private key passphrase:
1612 : lha@@nutcracker ; klist
1613 Credentials cache: FILE:/tmp/krb5cc_19100a
1614 Principal: lha@@EXAMPLE.ORG
1616 Issued Expires Principal
1617 Apr 20 02:08:08 Apr 20 12:08:08 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
1620 Using PKCS#11 it can look like this instead:
1623 $ kinit -C PKCS11:/usr/heimdal/lib/hx509.so lha@@EXAMPLE.ORG
1624 PIN code for SoftToken (slot):
1626 Credentials cache: API:4
1627 Principal: lha@@EXAMPLE.ORG
1629 Issued Expires Principal
1630 Mar 26 23:40:10 Mar 27 09:40:10 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
1633 @section Configure the client
1637 pkinit_anchors = FILE:/path/to/trust-anchors.pem
1641 pkinit_require_eku = true
1642 pkinit_require_krbtgt_otherName = true
1644 pkinit_win2k_require_binding = yes
1649 @section Configure the KDC
1651 Configuration options for the KDC.
1654 @item enable-pkinit = bool
1656 Enable PKINIT for this KDC.
1658 @item pkinit_identity = string
1660 Identity that the KDC will use when talking to clients. Mandatory.
1662 @item pkinit_anchors = string
1664 Trust anchors that the KDC will use when evaluating the trust of the
1665 client certificate. Mandatory.
1667 @item pkinit_pool = strings ...
1669 Extra certificate the KDC will use when building trust chains if it
1670 can't find enough certificates in the request from the client.
1672 @item pkinit_allow_proxy_certificate = bool
1674 Allow clients to use proxy certificates. The root certificate
1675 of the client's End Entity certificate is used for authorisation.
1677 @item pkinit_win2k_require_binding = bool
1679 Require windows clients up be upgrade to not allow cut and paste
1680 attack on encrypted data, applies to Windows XP and windows 2000
1683 @item pkinit_principal_in_certificate = bool
1685 Enable the KDC to use id-pkinit-san to determine to determine the
1686 mapping between a certificate and principal.
1693 pkinit_identity = FILE:/secure/kdc.crt,/secure/kdc.key
1694 pkinit_anchors = FILE:/path/to/trust-anchors.pem
1695 pkinit_pool = PKCS12:/path/to/useful-intermediate-certs.pfx
1696 pkinit_pool = FILE:/path/to/other-useful-intermediate-certs.pem
1697 pkinit_allow_proxy_certificate = no
1698 pkinit_win2k_require_binding = yes
1699 pkinit_principal_in_certificate = no
1702 @subsection Using pki-mapping file
1704 Note that the file contents are space sensitive.
1707 # cat /var/heimdal/pki-mapping
1708 # comments starts with #
1709 lha@@EXAMPLE.ORG:C=SE,O=Stockholm universitet,CN=Love,UID=lha
1710 lha@@EXAMPLE.ORG:CN=Love,UID=lha
1713 @subsection Using the Kerberos database
1715 You can also store the subject of the certificate in the principal
1716 entry in the kerberos database.
1719 kadmin modify --pkinit-acl="CN=baz,DC=test,DC=h5l,DC=se" user@@REALM
1722 @section Use hxtool to create certificates
1724 @subsection Generate certificates
1726 First, you need to generate a CA certificate. This example creates a
1727 CA certificate that will be valid for 10 years.
1729 You need to change --subject in the command below to something
1730 appropriate for your site.
1733 hxtool issue-certificate \
1736 --generate-key=rsa \
1737 --subject="CN=CA,DC=test,DC=h5l,DC=se" \
1738 --lifetime=10years \
1739 --certificate="FILE:ca.pem"
1742 The KDC needs to have a certificate, so generate a certificate of the
1743 type ``pkinit-kdc'' and set the PK-INIT specifial SubjectAltName to the
1744 name of the krbtgt of the realm.
1746 You need to change --subject and --pk-init-principal in the command
1747 below to something appropriate for your site.
1750 hxtool issue-certificate \
1751 --ca-certificate=FILE:ca.pem \
1752 --generate-key=rsa \
1753 --type="pkinit-kdc" \
1754 --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \
1755 --subject="uid=kdc,DC=test,DC=h5l,DC=se" \
1756 --certificate="FILE:kdc.pem"
1759 The users also needs to have certificates. For your first client,
1760 generate a certificate of type ``pkinit-client''. The client doesn't
1761 need to have the PK-INIT SubjectAltName set; you can have the Subject
1762 DN in the ACL file (pki-mapping) instead.
1764 You need to change --subject and --pk-init-principal in the command
1765 below to something appropriate for your site. You can omit
1766 --pk-init-principal if you're going to use the ACL file instead.
1769 hxtool issue-certificate \
1770 --ca-certificate=FILE:ca.pem \
1771 --generate-key=rsa \
1772 --type="pkinit-client" \
1773 --pk-init-principal="lha@@TEST.H5L.SE" \
1774 --subject="uid=lha,DC=test,DC=h5l,DC=se" \
1775 --certificate="FILE:user.pem"
1778 @subsection Validate the certificate
1780 hxtool also contains a tool that will validate certificates according
1781 to rules from the PKIX document. These checks are not complete, but
1782 they provide a good test of whether you got all of the basic bits
1783 right in your certificates.
1786 hxtool validate FILE:user.pem
1789 @section Use OpenSSL to create certificates
1790 @anchor{Use OpenSSL to create certificates}
1792 This section tries to give the CA owners hints how to create
1793 certificates using OpenSSL (or CA software based on OpenSSL).
1795 @subsection Using OpenSSL to create certificates with krb5PrincipalName
1797 To make OpenSSL create certificates with krb5PrincipalName, use an
1798 @file{openssl.cnf} as described below. To see a complete example of
1799 creating client and KDC certificates, see the test-data generation
1800 script @file{lib/hx509/data/gen-req.sh} in the source-tree. The
1801 certicates it creates are used to test the PK-INIT functionality in
1802 @file{tests/kdc/check-kdc.in}.
1804 To use this example you have to use OpenSSL 0.9.8a or later.
1809 subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:princ_name
1812 realm = EXP:0, GeneralString:MY.REALM
1813 principal_name = EXP:1, SEQUENCE:principal_seq
1816 name_type = EXP:0, INTEGER:1
1817 name_string = EXP:1, SEQUENCE:principals
1820 princ1 = GeneralString:userid
1827 openssl x509 -extensions user_certificate
1828 openssl ca -extensions user_certificate
1832 @c --- ms certificate
1835 @c msCertificateTemplateName = 1.3.6.1.4.1.311.20.2
1838 @c [ req_smartcard ]
1839 @c keyUsage = digitalSignature, keyEncipherment
1840 @c extendedKeyUsage = msSmartcardLogin, clientAuth
1841 @c msCertificateTemplateName = ASN1:BMP:SmartcardLogon
1842 @c subjectAltName = otherName:msUPN;UTF8:lukeh@dsg.padl.com
1843 @c #subjectAltName = email:copy
1846 @section Using PK-INIT with Windows
1848 @subsection Client configration
1850 Clients using a Windows KDC with PK-INIT need configuration since
1851 windows uses pre-standard format and this can't be autodetected.
1853 The pkinit_win2k_require_binding option requires the reply for the KDC
1854 to be of the new, secure, type that binds the request to
1855 reply. Before, clients could fake the reply from the KDC. To use this
1856 option you have to apply a fix from Microsoft.
1862 pkinit_win2k_require_binding = no
1866 @subsection Certificates
1868 The client certificates need to have the extended keyusage ``Microsoft
1869 Smartcardlogin'' (openssl has the OID shortname msSmartcardLogin).
1871 See Microsoft Knowledge Base Article - 281245 ``Guidelines for Enabling
1872 Smart Card Logon with Third-Party Certification Authorities'' for a
1873 more extensive description of how set setup an external CA so that it
1874 includes all the information required to make a Windows KDC happy.
1876 @subsection Configure Windows 2000 CA
1878 To enable Microsoft Smartcardlogin for certificates in your Windows
1879 2000 CA, you want to look at Microsoft Knowledge Base Article - 313274
1880 ``HOW TO: Configure a Certification Authority to Issue Smart Card
1881 Certificates in Windows''.
1883 @node Debugging Kerberos problems, , Setting up PK-INIT, Setting up a realm
1884 @section Debugging Kerberos problems
1886 To debug Kerberos client and server problems you can enable debug
1887 tracing by adding the following to @file{/etc/krb5.conf}. Note that the
1888 trace logging is sparse at the moment, but will continue to improve.
1892 libkrb5 = 0-/SYSLOG: