1@c Id 2@c $NetBSD: setup.texi,v 1.1.1.2 2011/04/14 14:08:09 elric Exp $ 3 4@node Setting up a realm, Applications, Building and Installing, Top 5 6@chapter Setting up a realm 7 8A 9@cindex realm 10realm is an administrative domain. The name of a Kerberos realm is 11usually the Internet domain name in uppercase. Call your realm the same 12as your Internet domain name if you do not have strong reasons for not 13doing so. It will make life easier for you and everyone else. 14 15@menu 16* Configuration file:: 17* Creating the database:: 18* Modifying the database:: 19* Checking the setup:: 20* keytabs:: 21* Serving Kerberos 4/524/kaserver:: 22* Remote administration:: 23* Password changing:: 24* Testing clients and servers:: 25* Slave Servers:: 26* Incremental propagation:: 27* Encryption types and salting:: 28* Credential cache server - KCM:: 29* Cross realm:: 30* Transit policy:: 31* Setting up DNS:: 32* Using LDAP to store the database:: 33* Providing Kerberos credentials to servers and programs:: 34* Setting up PK-INIT:: 35* Debugging Kerberos problems:: 36@end menu 37 38@node Configuration file, Creating the database, Setting up a realm, Setting up a realm 39@section Configuration file 40 41To setup a realm you will first have to create a configuration file: 42@file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many 43configuration options, some of which are described here. 44 45There is a sample @file{krb5.conf} supplied with the distribution. 46 47The configuration file is a hierarchical structure consisting of 48sections, each containing a list of bindings (either variable 49assignments or subsections). A section starts with 50@samp{[@samp{section-name}]}. A binding consists of a left hand side, an equal sign 51(@samp{=}) and a right hand side (the left hand side tag must be 52separated from the equal sign with some whitespace). Subsections have a 53@samp{@{} as the first non-whitespace character after the equal sign. All 54other bindings are treated as variable assignments. The value of a 55variable extends to the end of the line. 56 57@example 58[section1] 59 a-subsection = @{ 60 var = value1 61 other-var = value with @{@} 62 sub-sub-section = @{ 63 var = 123 64 @} 65 @} 66 var = some other value 67[section2] 68 var = yet another value 69@end example 70 71In this manual, names of sections and bindings will be given as strings 72separated by slashes (@samp{/}). The @samp{other-var} variable will thus 73be @samp{section1/a-subsection/other-var}. 74 75For in-depth information about the contents of the configuration file, refer to 76the @file{krb5.conf} manual page. Some of the more important sections 77are briefly described here. 78 79The @samp{libdefaults} section contains a list of library configuration 80parameters, such as the default realm and the timeout for KDC 81responses. The @samp{realms} section contains information about specific 82realms, such as where they hide their KDC@. This section serves the same 83purpose as the Kerberos 4 @file{krb.conf} file, but can contain more 84information. Finally the @samp{domain_realm} section contains a list of 85mappings from domains to realms, equivalent to the Kerberos 4 86@file{krb.realms} file. 87 88To continue with the realm setup, you will have to create a configuration file, 89with contents similar to the following. 90 91@example 92[libdefaults] 93 default_realm = MY.REALM 94[realms] 95 MY.REALM = @{ 96 kdc = my.kdc my.slave.kdc 97 kdc = my.third.kdc 98 kdc = 130.237.237.17 99 kdc = [2001:6b0:1:ea::100]:88 100 @} 101[domain_realm] 102 .my.domain = MY.REALM 103 104@end example 105 106If you use a realm name equal to your domain name, you can omit the 107@samp{libdefaults}, and @samp{domain_realm}, sections. If you have a DNS 108SRV-record for your realm, or your Kerberos server has DNS CNAME 109@samp{kerberos.my.realm}, you can omit the @samp{realms} section too. 110 111@node Creating the database, Modifying the database, Configuration file, Setting up a realm 112@section Creating the database 113 114The database library will look for the database in the directory 115@file{@value{dbdir}}, so you should probably create that directory. 116Make sure the directory has restrictive permissions. 117 118@example 119# mkdir /var/heimdal 120@end example 121 122The keys of all the principals are stored in the database. If you 123choose to, these can be encrypted with a master key. You do not have to 124remember this key (or password), but just to enter it once and it will 125be stored in a file (@file{/var/heimdal/m-key}). If you want to have a 126master key, run @samp{kstash} to create this master key: 127 128@example 129# kstash 130Master key: 131Verifying password - Master key: 132@end example 133 134If you want to generate a random master key you can use the 135@kbd{--random-key} flag to kstash. This will make sure you have a good key 136on which attackers can't do a dictionary attack. 137 138If you have a master key, make sure you make a backup of your master 139key file; without it backups of the database are of no use. 140 141To initialise the database use the @command{kadmin} program, with the 142@kbd{-l} option (to enable local database mode). First issue a 143@kbd{init MY.REALM} command. This will create the database and insert 144default principals for that realm. You can have more than one realm in 145one database, so @samp{init} does not destroy any old database. 146 147Before creating the database, @samp{init} will ask you some questions 148about maximum ticket lifetimes. 149 150After creating the database you should probably add yourself to it. You 151do this with the @samp{add} command. It takes as argument the name of a 152principal. The principal should contain a realm, so if you haven't set up 153a default realm, you will need to explicitly include the realm. 154 155@example 156# kadmin -l 157kadmin> init MY.REALM 158Realm max ticket life [unlimited]: 159Realm max renewable ticket life [unlimited]: 160kadmin> add me 161Max ticket life [unlimited]: 162Max renewable life [unlimited]: 163Attributes []: 164Password: 165Verifying password - Password: 166@end example 167 168Now start the KDC and try getting a ticket. 169 170@example 171# kdc & 172# kinit me 173me@@MY.REALMS's Password: 174# klist 175Credentials cache: /tmp/krb5cc_0 176 Principal: me@@MY.REALM 177 178 Issued Expires Principal 179Aug 25 07:25:55 Aug 25 17:25:55 krbtgt/MY.REALM@@MY.REALM 180@end example 181 182If you are curious you can use the @samp{dump} command to list all the 183entries in the database. It should look something similar to the 184following example (note that the entries here are truncated for 185typographical reasons): 186 187@smallexample 188kadmin> dump 189me@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ... 190kadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ... 191krbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ... 192kadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ... 193@end smallexample 194 195@node Modifying the database, Checking the setup, Creating the database, Setting up a realm 196@section Modifying the database 197 198All modifications of principals are done with with kadmin. 199 200A principal has several attributes and lifetimes associated with it. 201 202Principals are added, renamed, modified, and deleted with the kadmin 203commands @samp{add}, @samp{rename}, @samp{modify}, @samp{delete}. 204Both interactive editing and command line flags can be used (use --help 205to list the available options). 206 207There are different kinds of types for the fields in the database; 208attributes, absolute time times and relative times. 209 210@subsection Attributes 211 212When doing interactive editing, attributes are listed with @samp{?}. 213 214The attributes are given in a comma (@samp{,}) separated list. 215Attributes are removed from the list by prefixing them with @samp{-}. 216 217@smallexample 218kadmin> modify me 219Max ticket life [1 day]: 220Max renewable life [1 week]: 221Principal expiration time [never]: 222Password expiration time [never]: 223Attributes [disallow-renewable]: requires-pre-auth,-disallow-renewable 224kadmin> get me 225 Principal: me@@MY.REALM 226[...] 227 Attributes: requires-pre-auth 228@end smallexample 229 230@subsection Absolute times 231 232The format for absolute times are any of the following: 233 234@smallexample 235never 236now 237YYYY-mm-dd 238YYYY-mm-dd HH:MM:SS 239@end smallexample 240 241 242@subsection Relative times 243 244The format for relative times are any of the following combined: 245 246@smallexample 247N year 248M month 249O day 250P hour 251Q minute 252R second 253@end smallexample 254 255@c Describe more of kadmin commands here... 256 257@node Checking the setup, keytabs, Modifying the database, Setting up a realm 258@section Checking the setup 259 260There are two tools that can check the consistency of the Kerberos 261configuration file and the Kerberos database. 262 263The Kerberos configuration file is checked using 264@command{verify_krb5_conf}. The tool checks for common errors, but 265commonly there are several uncommon configuration entries that are 266never added to the tool and thus generates ``unknown entry'' warnings. 267This is usually nothing to worry about. 268 269The database check is built into the kadmin tool. It will check for 270common configuration error that will cause problems later. Common 271check are for existence and flags on important principals. The 272database check by run by the following command : 273 274@example 275kadmin -l check REALM.EXAMPLE.ORG 276@end example 277 278@node keytabs, Serving Kerberos 4/524/kaserver, Checking the setup, Setting up a realm 279@section keytabs 280 281To extract a service ticket from the database and put it in a keytab, you 282need to first create the principal in the database with @samp{add} 283(using the @kbd{--random-key} flag to get a random key) and then 284extract it with @samp{ext_keytab}. 285 286@example 287kadmin> add --random-key host/my.host.name 288Max ticket life [unlimited]: 289Max renewable life [unlimited]: 290Attributes []: 291kadmin> ext host/my.host.name 292kadmin> exit 293# ktutil list 294Version Type Principal 295 1 des-cbc-md5 host/my.host.name@@MY.REALM 296 1 des-cbc-md4 host/my.host.name@@MY.REALM 297 1 des-cbc-crc host/my.host.name@@MY.REALM 298 1 des3-cbc-sha1 host/my.host.name@@MY.REALM 299@end example 300 301@node Serving Kerberos 4/524/kaserver, Remote administration, keytabs, Setting up a realm 302@section Serving Kerberos 4/524/kaserver 303 304Heimdal can be configured to support 524, Kerberos 4 or kaserver. All 305these services are turned off by default. Kerberos 4 is always 306supported by the KDC, but the Kerberos 4 client support also depends 307on Kerberos 4 support having been included at compile-time, using 308@kbd{--with-krb4=dir}. 309 310@subsection 524 311 312524 is a service that allows the KDC to convert Kerberos 5 tickets to 313Kerberos 4 tickets for backward compatibility. See also Using 2b 314tokens with AFS in @xref{AFS}. 315 316524 can be turned on by adding this to the configuration file 317 318@example 319[kdc] 320 enable-524 = yes 321@end example 322 323@subsection Kerberos 4 324 325Kerberos 4 is the predecessor to to Kerberos 5. It only supports 326single DES@. You should only enable Kerberos 4 support if you have 327needs for compatibility with an installed base of Kerberos 4 328clients/servers. 329 330Kerberos 4 can be turned on by adding this to the configuration file 331 332@example 333[kdc] 334 enable-kerberos4 = yes 335@end example 336 337@subsection kaserver 338 339Kaserver is a Kerberos 4 that is used in AFS@. The protocol has some 340extra features over plain Kerberos 4, but like Kerberos 4, only uses 341single DES@. 342 343You should only enable Kaserver support if you have needs for 344compatibility with an installed base of AFS machines. 345 346Kaserver can be turned on by adding this to the configuration file 347 348@example 349[kdc] 350 enable-kaserver = yes 351@end example 352 353@node Remote administration, Password changing, Serving Kerberos 4/524/kaserver, Setting up a realm 354@section Remote administration 355 356The administration server, @command{kadmind}, can be started by 357@command{inetd} (which isn't recommended) or run as a normal daemon. If you 358want to start it from @command{inetd} you should add a line similar to the 359one below to your @file{/etc/inetd.conf}. 360 361@example 362kerberos-adm stream tcp nowait root /usr/heimdal/libexec/kadmind kadmind 363@end example 364 365You might need to add @samp{kerberos-adm} to your @file{/etc/services} 366as @samp{749/tcp}. 367 368Access to the administration server is controlled by an ACL file, 369(default @file{/var/heimdal/kadmind.acl}.) The file has the following 370syntax: 371@smallexample 372principal [priv1,priv2,...] [glob-pattern] 373@end smallexample 374 375The matching is from top to bottom for matching principals (and if given, 376glob-pattern). When there is a match, the access rights of that line are 377applied. 378 379The privileges you can assign to a principal are: @samp{add}, 380@samp{change-password} (or @samp{cpw} for short), @samp{delete}, 381@samp{get}, @samp{list}, and @samp{modify}, or the special privilege 382@samp{all}. All of these roughly correspond to the different commands 383in @command{kadmin}. 384 385If a @var{glob-pattern} is given on a line, it restricts the access 386rights for the principal to only apply for subjects that match the 387pattern. The patterns are of the same type as those used in shell 388globbing, see @url{none,,fnmatch(3)}. 389 390In the example below @samp{lha/admin} can change every principal in the 391database. @samp{jimmy/admin} can only modify principals that belong to 392the realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the 393help desk, so he should only be able to change the passwords for single 394component principals (ordinary users). He will not be able to change any 395@samp{/admin} principal. 396 397@example 398lha/admin@@E.KTH.SE all 399jimmy/admin@@E.KTH.SE all *@@E.KTH.SE 400jimmy/admin@@E.KTH.SE all */*@@E.KTH.SE 401mille/admin@@E.KTH.SE change-password *@@E.KTH.SE 402@end example 403 404@node Password changing, Testing clients and servers, Remote administration, Setting up a realm 405@section Password changing 406 407To allow users to change their passwords, you should run @command{kpasswdd}. 408It is not run from @command{inetd}. 409 410You might need to add @samp{kpasswd} to your @file{/etc/services} as 411@samp{464/udp}. If your realm is not setup to use DNS, you might also 412need to add a @samp{kpasswd_server} entry to the realm configuration 413in @file{/etc/krb5.conf} on client machines: 414 415@example 416[realms] 417 MY.REALM = @{ 418 kdc = my.kdc my.slave.kdc 419 kpasswd_server = my.kdc 420 @} 421@end example 422 423@subsection Password quality assurance 424 425It is important that users have good passwords, both to make it harder 426to guess them and to avoid off-line attacks (although 427pre-authentication provides some defence against off-line attacks). 428To ensure that the users choose good passwords, you can enable 429password quality controls in @command{kpasswdd} and @command{kadmind}. 430The controls themselves are done in a shared library or an external 431program that is used by @command{kpasswdd}. To configure in these 432controls, add lines similar to the following to your 433@file{/etc/krb5.conf}: 434 435@example 436[password_quality] 437 policies = external-check builtin:minimum-length modulename:policyname 438 external_program = /bin/false 439 policy_libraries = @var{library1.so} @var{library2.so} 440@end example 441 442In @samp{[password_quality]policies} the module name is optional if 443the policy name is unique in all modules (members of 444@samp{policy_libraries}). All built-in policies can be qualified with 445a module name of @samp{builtin} to unambiguously specify the built-in 446policy and not a policy by the same name from a loaded module. 447 448The built-in policies are 449 450@itemize @bullet 451 452@item external-check 453 454Executes the program specified by @samp{[password_quality]external_program}. 455 456A number of key/value pairs are passed as input to the program, one per 457line, ending with the string @samp{end}. The key/value lines are of 458the form 459@example 460principal: @var{principal} 461new-password: @var{password} 462@end example 463where @var{password} is the password to check for the previous 464@var{principal}. 465 466If the external application approves the password, it should return 467@samp{APPROVED} on standard out and exit with exit code 0. If it 468doesn't approve the password, an one line error message explaining the 469problem should be returned on standard error and the application 470should exit with exit code 0. In case of a fatal error, the 471application should, if possible, print an error message on standard 472error and exit with a non-zero error code. 473 474@item minimum-length 475 476The minimum length password quality check reads the configuration file 477stanza @samp{[password_quality]min_length} and requires the password 478to be at least this length. 479 480@item character-class 481 482The character-class password quality check reads the configuration 483file stanza @samp{[password_quality]min_classes}. The policy requires 484the password to have characters from at least that many character 485classes. Default value if not given is 3. 486 487The four different characters classes are, uppercase, lowercase, 488number, special characters. 489 490@end itemize 491 492If you want to write your own shared object to check password 493policies, see the manual page @manpage{kadm5_pwcheck,3}. 494 495Code for a password quality checking function that uses the cracklib 496library can be found in @file{lib/kadm5/sample_password_check.c} in 497the source code distribution. It requires that the cracklib library 498be built with the patch available at 499@url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}. 500 501A sample policy external program is included in 502@file{lib/kadm5/check-cracklib.pl}. 503 504If no password quality checking function is configured, the only check 505performed is that the password is at least six characters long. 506 507To check the password policy settings, use the command 508@command{verify-password-quality} in @command{kadmin} program. The password 509verification is only performed locally, on the client. It may be 510convenient to set the environment variable @samp{KRB5_CONFIG} to point 511to a test version of @file{krb5.conf} while you're testing the 512@samp{[password_quality]} stanza that way. 513 514@node Testing clients and servers, Slave Servers, Password changing, Setting up a realm 515@section Testing clients and servers 516 517Now you should be able to run all the clients and servers. Refer to the 518appropriate man pages for information on how to use them. 519 520@node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm 521@section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm 522 523It is desirable to have at least one backup (slave) server in case the 524master server fails. It is possible to have any number of such slave 525servers but more than three usually doesn't buy much more redundancy. 526 527All Kerberos servers for a realm must have the same database so that 528they present the same service to the users. The 529@pindex hprop 530@command{hprop} program, running on the master, will propagate the database 531to the slaves, running 532@pindex hpropd 533@command{hpropd} processes. 534 535Every slave needs a database directory, the master key (if it was used 536for the database) and a keytab with the principal 537@samp{hprop/@var{hostname}}. Add the principal with the 538@pindex ktutil 539@command{ktutil} command and start 540@pindex hpropd 541@command{hpropd}, as follows: 542 543@example 544slave# ktutil get -p foo/admin hprop/`hostname` 545slave# mkdir /var/heimdal 546slave# hpropd 547@end example 548 549The master will use the principal @samp{kadmin/hprop} to authenticate to 550the slaves. This principal should be added when running @kbd{kadmin -l 551init} but if you do not have it in your database for whatever reason, 552please add it with @kbd{kadmin -l add}. 553 554Then run 555@pindex hprop 556@code{hprop} on the master: 557 558@example 559master# hprop slave 560@end example 561 562This was just an hands-on example to make sure that everything was 563working properly. Doing it manually is of course the wrong way, and to 564automate this you will want to start 565@pindex hpropd 566@command{hpropd} from @command{inetd} on the slave(s) and regularly run 567@pindex hprop 568@command{hprop} on the master to regularly propagate the database. 569Starting the propagation once an hour from @command{cron} is probably a 570good idea. 571 572@node Incremental propagation, Encryption types and salting, Slave Servers, Setting up a realm 573@section Incremental propagation 574 575There is also a newer mechanism for 576doing incremental propagation in Heimdal. Instead of sending the whole 577database regularly, it sends the changes as they happen on the master to 578the slaves. The master keeps track of all the changes by assigning a 579version number to every change to the database. The slaves know which 580was the latest version they saw and in this way it can be determined if 581they are in sync or not. A log of all the changes is kept on the master, 582and when a slave is at an older version than the oldest one in the 583log, the whole database has to be sent. 584 585Protocol-wise, all the slaves connect to the master and as a greeting 586tell it the latest version that they have (@samp{IHAVE} message). The 587master then responds by sending all the changes between that version and 588the current version at the master (a series of @samp{FORYOU} messages) 589or the whole database in a @samp{TELLYOUEVERYTHING} message. There is 590also a keep-alive protocol that makes sure all slaves are up and running. 591 592In addition on listening on the network to get connection from new 593slaves, the ipropd-master also listens on a status unix 594socket. kadmind and kpasswdd both open that socket when a transation 595is done and written a notification to the socket. That cause 596ipropd-master to check for new version in the log file. As a fallback in 597case a notification is lost by the unix socket, the log file is 598checked after 30 seconds of no event. 599 600@subsection Configuring incremental propagation 601 602The program that runs on the master is @command{ipropd-master} and all 603clients run @command{ipropd-slave}. 604 605Create the file @file{/var/heimdal/slaves} on the master containing all 606the slaves that the database should be propagated to. Each line contains 607the full name of the principal (for example 608@samp{iprop/hemligare.foo.se@@FOO.SE}). 609 610You should already have @samp{iprop/tcp} defined as 2121, in your 611@file{/etc/services}. Otherwise, or if you need to use a different port 612for some peculiar reason, you can use the @kbd{--port} option. This is 613useful when you have multiple realms to distribute from one server. 614 615Then you need to create those principals that you added in the 616configuration file. Create one @samp{iprop/hostname} for the master and 617for every slave. 618 619 620@example 621master# /usr/heimdal/sbin/ktutil get iprop/`hostname` 622@end example 623 624@example 625slave# /usr/heimdal/sbin/ktutil get iprop/`hostname` 626@end example 627 628 629The next step is to start the @command{ipropd-master} process on the master 630server. The @command{ipropd-master} listens on the UNIX domain socket 631@file{/var/heimdal/signal} to know when changes have been made to the 632database so they can be propagated to the slaves. There is also a 633safety feature of testing the version number regularly (every 30 634seconds) to see if it has been modified by some means that do not raise 635this signal. Then, start @command{ipropd-slave} on all the slaves: 636 637@example 638master# /usr/heimdal/libexec/ipropd-master & 639slave# /usr/heimdal/libexec/ipropd-slave master & 640@end example 641 642To manage the iprop log file you should use the @command{iprop-log} 643command. With it you can dump, truncate and replay the logfile. 644 645@node Encryption types and salting, Credential cache server - KCM, Incremental propagation, Setting up a realm 646@section Encryption types and salting 647@cindex Salting 648@cindex Encryption types 649 650The encryption types that the KDC is going to assign by default is 651possible to change. Since the keys used for user authentication is 652salted the encryption types are described together with the salt 653strings. 654 655Salting is used to make it harder to pre-calculate all possible 656keys. Using a salt increases the search space to make it almost 657impossible to pre-calculate all keys. Salting is the process of mixing a 658public string (the salt) with the password, then sending it through an 659encryption type specific string-to-key function that will output the 660fixed size encryption key. 661 662In Kerberos 5 the salt is determined by the encryption type, except in 663some special cases. 664 665In @code{des} there is the Kerberos 4 salt 666(none at all) or the afs-salt (using the cell (realm in 667AFS lingo)). 668 669In @code{arcfour} (the encryption type that Microsoft Windows 2000 uses) 670there is no salt. This is to be compatible with NTLM keys in Windows 671NT 4. 672 673@code{[kadmin]default_keys} in @file{krb5.conf} controls 674what salting to use. 675 676The syntax of @code{[kadmin]default_keys} is 677@samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption 678type (des-cbc-crc, arcfour-hmac-md5, aes256-cts-hmac-sha1-96), 679@code{salt-type} is the type of salt (pw-salt or afs3-salt), and the 680salt-string is the string that will be used as salt (remember that if 681the salt is appended/prepended, the empty salt "" is the same thing as 682no salt at all). 683 684Common types of salting include 685 686@itemize @bullet 687@item @code{v4} (or @code{des:pw-salt:}) 688 689The Kerberos 4 salting is using no salt at all. Reason there is colon 690at the end of the salt string is that it makes the salt the empty 691string (same as no salt). 692 693@item @code{v5} (or @code{pw-salt}) 694 695@code{pw-salt} uses the default salt for each encryption type is 696specified for. If the encryption type @samp{etype} isn't given, all 697default encryption will be used. 698 699@item @code{afs3-salt} 700 701@code{afs3-salt} is the salt that is used with Transarc kaserver. It's 702the cell name appended to the password. 703 704@end itemize 705 706@node Credential cache server - KCM, Cross realm, Encryption types and salting, Setting up a realm 707@section Credential cache server - KCM 708@cindex KCM 709@cindex Credential cache server 710 711When KCM running is easy for users to switch between different 712kerberos principals using @file{kswitch} or built in support in 713application, like OpenSSH's GSSAPIClientIdentity. 714 715Other advantages are that there is the long term credentials are not 716written to disk and on reboot the credential is removed when kcm 717process stopps running. 718 719Configure the system startup script to start the kcm process, 720@file{/usr/heimdal/libexec/kcm} and then configure the system to use kcm in @file{krb5.conf}. 721 722@example 723[libdefaults] 724 default_cc_type = KCM 725@end example 726 727Now when you run @command{kinit} it doesn't overwrite your existing 728credentials but rather just add them to the set of 729credentials. @command{klist -l} lists the credentials and the star 730marks the default credential. 731 732@example 733$ kinit lha@@KTH.SE 734lha@@KTH.SE's Password: 735$ klist -l 736 Name Cache name Expires 737lha@@KTH.SE 0 Nov 22 23:09:40 * 738lha@@SU.SE Initial default ccache Nov 22 14:14:24 739@end example 740 741When switching between credentials you can use @command{kswitch}. 742 743@example 744$ kswitch -i 745 Principal 7461 lha@@KTH.SE 7472 lha@@SU.SE 748Select number: 2 749@end example 750 751After switching, a new set of credentials are used as default. 752 753@example 754$ klist -l 755 Name Cache name Expires 756lha@@SU.SE Initial default ccache Nov 22 14:14:24 * 757lha@@KTH.SE 0 Nov 22 23:09:40 758@end example 759 760Som applications, like openssh with Simon Wilkinsons patch applied, 761support specifiying that credential to use. The example below will 762login to the host computer.kth.se using lha@@KTH.SE (not the current 763default credential). 764 765@example 766$ ssh \ 767 -o GSSAPIAuthentication=yes \ 768 -o GSSAPIKeyExchange=yes \ 769 -o GSSAPIClientIdentity=lha@@KTH.SE \ 770 computer.kth.se 771@end example 772 773 774 775@node Cross realm, Transit policy, Credential cache server - KCM, Setting up a realm 776@section Cross realm 777@cindex Cross realm 778 779Suppose you reside in the realm @samp{MY.REALM}, how do you 780authenticate to a server in @samp{OTHER.REALM}? Having valid tickets in 781@samp{MY.REALM} allows you to communicate with Kerberised services in that 782realm. However, the computer in the other realm does not have a secret 783key shared with the Kerberos server in your realm. 784 785It is possible to share keys between two realms that trust each 786other. When a client program, such as @command{telnet} or @command{ssh}, 787finds that the other computer is in a different realm, it will try to 788get a ticket granting ticket for that other realm, but from the local 789Kerberos server. With that ticket granting ticket, it will then obtain 790service tickets from the Kerberos server in the other realm. 791 792For a two way trust between @samp{MY.REALM} and @samp{OTHER.REALM} 793add the following principals to each realm. The principals should be 794@samp{krbtgt/OTHER.REALM@@MY.REALM} and 795@samp{krbtgt/MY.REALM@@OTHER.REALM} in @samp{MY.REALM}, and 796@samp{krbtgt/MY.REALM@@OTHER.REALM} and 797@samp{krbtgt/OTHER.REALM@@MY.REALM}in @samp{OTHER.REALM}. 798 799In Kerberos 5 the trust can be configured to be one way. So that 800users from @samp{MY.REALM} can authenticate to services in 801@samp{OTHER.REALM}, but not the opposite. In the example above, the 802@samp{krbtgt/MY.REALM@@OTHER.REALM} then should be removed. 803 804The two principals must have the same key, key version number, and the 805same set of encryption types. Remember to transfer the two keys in a 806safe manner. 807 808@example 809vr$ klist 810Credentials cache: FILE:/tmp/krb5cc_913.console 811 Principal: lha@@E.KTH.SE 812 813 Issued Expires Principal 814May 3 13:55:52 May 3 23:55:54 krbtgt/E.KTH.SE@@E.KTH.SE 815 816vr$ telnet -l lha hummel.it.su.se 817Trying 2001:6b0:5:1095:250:fcff:fe24:dbf... 818Connected to hummel.it.su.se. 819Escape character is '^]'. 820Waiting for encryption to be negotiated... 821[ Trying mutual KERBEROS5 (host/hummel.it.su.se@@SU.SE)... ] 822[ Kerberos V5 accepts you as ``lha@@E.KTH.SE'' ] 823Encryption negotiated. 824Last login: Sat May 3 14:11:47 from vr.l.nxs.se 825hummel$ exit 826 827vr$ klist 828Credentials cache: FILE:/tmp/krb5cc_913.console 829 Principal: lha@@E.KTH.SE 830 831 Issued Expires Principal 832May 3 13:55:52 May 3 23:55:54 krbtgt/E.KTH.SE@@E.KTH.SE 833May 3 13:55:56 May 3 23:55:54 krbtgt/SU.SE@@E.KTH.SE 834May 3 14:10:54 May 3 23:55:54 host/hummel.it.su.se@@SU.SE 835 836@end example 837 838@node Transit policy, Setting up DNS, Cross realm, Setting up a realm 839@section Transit policy 840@cindex Transit policy 841 842Under some circumstances, you may not wish to set up direct 843cross-realm trust with every realm to which you wish to authenticate 844or from which you wish to accept authentications. Kerberos supports 845multi-hop cross-realm trust where a client principal in realm A 846authenticates to a service in realm C through a realm B with which 847both A and C have cross-realm trust relationships. In this situation, 848A and C need not set up cross-realm principals between each other. 849 850If you want to use cross-realm authentication through an intermediate 851realm, it must be explicitly allowed by either the KDCs for the realm 852to which the client is authenticating (in this case, realm C), or the 853server receiving the request. This is done in @file{krb5.conf} in the 854@code{[capaths]} section. 855 856In addition, the client in realm A need to be configured to know how 857to reach realm C via realm B. This can be done either on the client or 858via KDC configuration in the KDC for realm A. 859 860@subsection Allowing cross-realm transits 861 862When the ticket transits through a realm to another realm, the 863destination realm adds its peer to the "transited-realms" field in the 864ticket. The field is unordered, since there is no way to know if know 865if one of the transited-realms changed the order of the list. For the 866authentication to be accepted by the final destination realm, all of 867the transited realms must be listed as trusted in the @code{[capaths]} 868configuration, either in the KDC for the destination realm or on the 869server receiving the authentication. 870 871The syntax for @code{[capaths]} section is: 872 873@example 874[capaths] 875 CLIENT-REALM = @{ 876 SERVER-REALM = PERMITTED-CROSS-REALMS ... 877 @} 878@end example 879 880In the following example, the realm @code{STACKEN.KTH.SE} only has 881direct cross-realm set up with @code{KTH.SE}. @code{KTH.SE} has 882direct cross-realm set up with @code{STACKEN.KTH.SE} and @code{SU.SE}. 883@code{DSV.SU.SE} only has direct cross-realm set up with @code{SU.SE}. 884The goal is to allow principals in the @code{DSV.SU.SE} or 885@code{SU.SE} realms to authenticate to services in 886@code{STACKEN.KTH.SE}. This is done with the following 887@code{[capaths]} entry on either the server accepting authentication 888or on the KDC for @code{STACKEN.KTH.SE}. 889 890@example 891[capaths] 892 SU.SE = @{ 893 STACKEN.KTH.SE = KTH.SE 894 @} 895 DSV.SU.SE = @{ 896 STACKEN.KTH.SE = SU.SE KTH.SE 897 @} 898@end example 899 900The first entry allows cross-realm authentication from clients in 901@code{SU.SE} transiting through @code{KTH.SE} to 902@code{STACKEN.KTH.SE}. The second entry allows cross-realm 903authentication from clients in @code{DSV.SU.SE} transiting through 904both @code{SU.SE} and @code{KTH.SE} to @code{STACKEN.KTH.SE}. 905 906Be careful of which realm goes where; it's easy to put realms in the 907wrong place. The block is tagged with the client realm (the realm of 908the principal authenticating), and the realm before the equal sign is 909the final destination realm: the realm to which the client is 910authenticating. After the equal sign go all the realms that the 911client transits through. 912 913The order of the @code{PERMITTED-CROSS-REALMS} is not important when 914doing transit cross realm verification. 915 916@subsection Configuring client cross-realm transits 917 918The @code{[capaths]} section is also used for another purpose: to tell 919clients which realm to transit through to reach a realm with which 920their local realm does not have cross-realm trust. This can be done 921by either putting a @code{[capaths]} entry in the configuration of the 922client or by putting the entry in the configuration of the KDC for the 923client's local realm. In the latter case, the KDC will then hand back 924a referral to the client when the client requests a cross-realm ticket 925to the destination realm, telling the client to try to go through an 926intermediate realm. 927 928For client configuration, the order of @code{PERMITTED-CROSS-REALMS} 929is significant, since only the first realm in this section (after the 930equal sign) is used by the client. 931 932For example, again consider the @code{[capaths]} entry above for the 933case of a client in the @code{SU.SE} realm, and assume that the client 934or the @code{SU.SE} KDC has that @code{[capaths]} entry. If the 935client attempts to authenticate to a service in the 936@code{STACKEN.KTH.SE} realm, that entry says to first authenticate 937cross-realm to the @code{KTH.SE} realm (the first realm listed in the 938@code{PERMITTED-CROSS-REALMS} section), and then from there to 939@code{STACKEN.KTH.SE}. 940 941Each entry in @code{[capaths]} can only give the next hop, since only 942the first realm in @code{PERMITTED-CROSS-REALMS} is used. If, for 943instance, a client in @code{DSV.SU.SE} had a @code{[capaths]} 944configuration as above but without the first block for @code{SU.SE}, 945they would not be able to reach @code{STACKEN.KTH.SE}. They would get 946as far as @code{SU.SE} based on the @code{DSV.SU.SE} entry in 947@code{[capaths]} and then attempt to go directly from there to 948@code{STACKEN.KTH.SE} and get stuck (unless, of course, the 949@code{SU.SE} KDC had the additional entry required to tell the client 950to go through @code{KTH.SE}). 951 952@subsection Active Directory forest example 953 954One common place where a @code{[capaths]} configuration is desirable 955is with Windows Active Directory forests. One common Active Directory 956configuration is to have one top-level Active Directory realm but then 957divide systems, services, and users into child realms (perhaps based 958on organizational unit). One generally establishes cross-realm trust 959only with the top-level realm, and then uses transit policy to permit 960authentications to and from the child realms. 961 962For example, suppose an organization has a Heimdal realm 963@code{EXAMPLE.COM}, a Windows Active Directory realm 964@code{WIN.EXAMPLE.COM}, and then child Active Directory realms 965@code{ENGR.WIN.EXAMPLE.COM} and @code{SALES.WIN.EXAMPLE.COM}. The 966goal is to allow users in any of these realms to authenticate to 967services in any of these realms. The @code{EXAMPLE.COM} KDC (and 968possibly client) configuration should therefore contain a 969@code{[capaths]} section as follows: 970 971@example 972[capaths] 973 ENGR.WIN.EXAMPLE.COM = @{ 974 EXAMPLE.COM = WIN.EXAMPLE.COM 975 @} 976 SALES.WIN.EXAMPLE.COM = @{ 977 EXAMPLE.COM = WIN.EXAMPLE.COM 978 @} 979 EXAMPLE.COM = @{ 980 ENGR.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM 981 SALES.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM 982 @} 983@end example 984 985The first two blocks allow clients in the @code{ENGR.WIN.EXAMPLE.COM} 986and @code{SALES.WIN.EXAMPLE.COM} realms to authenticate to services in 987the @code{EXAMPLE.COM} realm. The third block tells the client (or 988tells the KDC to tell the client via referrals) to transit through 989@code{WIN.EXAMPLE.COM} to reach these realms. Both sides of the 990configuration are needed for bi-directional transited cross-realm 991authentication. 992 993@c To test the cross realm configuration, use: 994@c kmumble transit-check client server transit-realms ... 995 996@node Setting up DNS, Using LDAP to store the database, Transit policy, Setting up a realm 997@section Setting up DNS 998@cindex Setting up DNS 999 1000@subsection Using DNS to find KDC 1001 1002If there is information about where to find the KDC or kadmind for a 1003realm in the @file{krb5.conf} for a realm, that information will be 1004preferred, and DNS will not be queried. 1005 1006Heimdal will try to use DNS to find the KDCs for a realm. First it 1007will try to find a @code{SRV} resource record (RR) for the realm. If no 1008SRV RRs are found, it will fall back to looking for an @code{A} RR for 1009a machine named kerberos.REALM, and then kerberos-1.REALM, etc 1010 1011Adding this information to DNS minimises the client configuration (in 1012the common case, resulting in no configuration needed) and allows the 1013system administrator to change the number of KDCs and on what machines 1014they are running without caring about clients. 1015 1016The downside of using DNS is that the client might be fooled to use the 1017wrong server if someone fakes DNS replies/data, but storing the IP 1018addresses of the KDC on all the clients makes it very hard to change 1019the infrastructure. 1020 1021An example of the configuration for the realm @code{EXAMPLE.COM}: 1022 1023@example 1024 1025$ORIGIN example.com. 1026_kerberos._tcp SRV 10 1 88 kerberos.example.com. 1027_kerberos._udp SRV 10 1 88 kerberos.example.com. 1028_kerberos._tcp SRV 10 1 88 kerberos-1.example.com. 1029_kerberos._udp SRV 10 1 88 kerberos-1.example.com. 1030_kpasswd._udp SRV 10 1 464 kerberos.example.com. 1031_kerberos-adm._tcp SRV 10 1 749 kerberos.example.com. 1032 1033@end example 1034 1035More information about DNS SRV resource records can be found in 1036RFC-2782 (A DNS RR for specifying the location of services (DNS SRV)). 1037 1038@subsection Using DNS to map hostname to Kerberos realm 1039 1040Heimdal also supports a way to lookup a realm from a hostname. This to 1041minimise configuration needed on clients. Using this has the drawback 1042that clients can be redirected by an attacker to realms within the 1043same cross realm trust and made to believe they are talking to the 1044right server (since Kerberos authentication will succeed). 1045 1046An example configuration that informs clients that for the realms 1047it.example.com and srv.example.com, they should use the realm 1048EXAMPLE.COM: 1049 1050@example 1051 1052$ORIGIN example.com. 1053_kerberos.it TXT "EXAMPLE.COM" 1054_kerberos.srv TXT "EXAMPLE.COM" 1055 1056@end example 1057 1058@node Using LDAP to store the database, Providing Kerberos credentials to servers and programs, Setting up DNS, Setting up a realm 1059@section Using LDAP to store the database 1060@cindex Using the LDAP backend 1061 1062This document describes how to install the LDAP backend for 1063Heimdal. Note that before attempting to configure such an 1064installation, you should be aware of the implications of storing 1065private information (such as users' keys) in a directory service 1066primarily designed for public information. Nonetheless, with a 1067suitable authorisation policy, it is possible to set this up in a 1068secure fashion. A knowledge of LDAP, Kerberos, and C is necessary to 1069install this backend. The HDB schema was devised by Leif Johansson. 1070 1071This assumes, OpenLDAP 2.3 or later. 1072 1073Requirements: 1074 1075@itemize @bullet 1076 1077@item 1078A current release of Heimdal, configured with 1079@code{--with-openldap=/usr/local} (adjust according to where you have 1080installed OpenLDAP). 1081 1082You can verify that you manage to configure LDAP support by running 1083@file{kdc --builtin-hdb}, and checking that @samp{ldap:} is one entry 1084in the list. 1085 1086Its also possible to configure the ldap backend as a shared module, 1087see option --hdb-openldap-module to configure. 1088 1089@item 1090Configure OpenLDAP with @kbd{--enable-local} to enable the local transport. 1091 1092@item 1093Add the hdb schema to the LDAP server, it's included in the source-tree 1094in @file{lib/hdb/hdb.schema}. Example from slapd.conf: 1095 1096@example 1097include /usr/local/etc/openldap/schema/hdb.schema 1098@end example 1099 1100@item 1101Configure the LDAP server ACLs to accept writes from clients over the 1102local transport. For example: 1103 1104@example 1105access to * 1106 by dn.exact="uid=heimdal,dc=services,dc=example,dc=com" write 1107 ... 1108 1109authz-regexp "gidNumber=.*\\\+uidNumber=0,cn=peercred,cn=external,cn=auth'' 1110 "uid=heimdal,dc=services,dc=example,dc=com" 1111 1112@end example 1113 1114The sasl-regexp is for mapping between the SASL/EXTERNAL and a user in 1115a tree. The user that the key is mapped to should be have a 1116krb5Principal aux object with krb5PrincipalName set so that the 1117``creator'' and ``modifier'' is right in @file{kadmin}. 1118 1119Another option is to create an admins group and add the dn to that 1120group. 1121 1122Since Heimdal talks to the LDAP server over a UNIX domain socket, and 1123uses external sasl authentication, it's not possible to require 1124security layer quality (ssf in cyrus-sasl lingo). So that requirement 1125has to be turned off in OpenLDAP @command{slapd} configuration file 1126@file{slapd.conf}. 1127 1128@example 1129sasl-secprops minssf=0 1130@end example 1131 1132@item 1133 1134Start @command{slapd} with the local listener (as well as the default TCP/IP 1135listener on port 389) as follows: 1136 1137@example 1138 slapd -h "ldapi:/// ldap:///" 1139@end example 1140 1141Note: These is a bug in @command{slapd} where it appears to corrupt the krb5Key 1142binary attribute on shutdown. This may be related to our use of the V3 1143schema definition syntax instead of the old UMich-style, V2 syntax. 1144 1145@item 1146You should specify the distinguished name under which your 1147principals will be stored in @file{krb5.conf}. Also you need to 1148enter the path to the kadmin acl file: 1149 1150 1151@example 1152[kdc] 1153 database = @{ 1154 dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com 1155 hdb-ldap-structural-object = inetOrgPerson 1156 acl_file = /path/to/kadmind.acl 1157 mkey_file = /path/to/mkey 1158 @} 1159@end example 1160 1161@samp{mkey_file} can be excluded if you feel that you trust your ldap 1162directory to have the raw keys inside it. The 1163hdb-ldap-structural-object is not necessary if you do not need Samba 1164comatibility. 1165 1166 1167 1168@item 1169Once you have built Heimdal and started the LDAP server, run kadmin 1170(as usual) to initialise the database. Note that the instructions for 1171stashing a master key are as per any Heimdal installation. 1172 1173@example 1174kdc# kadmin -l 1175kadmin> init EXAMPLE.COM 1176Realm max ticket life [unlimited]: 1177Realm max renewable ticket life [unlimited]: 1178kadmin> add lukeh 1179Max ticket life [1 day]: 1180Max renewable life [1 week]: 1181Principal expiration time [never]: 1182Password expiration time [never]: 1183Attributes []: 1184lukeh@@EXAMPLE.COM's Password: 1185Verifying password - lukeh@@EXAMPLE.COM's Password: 1186kadmin> exit 1187@end example 1188 1189Verify that the principal database has indeed been stored in the 1190directory with the following command: 1191 1192@example 1193kdc# ldapsearch -L -h localhost -D cn=manager \ 1194 -w secret -b ou=KerberosPrincipals,dc=example,dc=com \ 1195 'objectclass=krb5KDCEntry' 1196@end example 1197 1198@item 1199Now consider adding indexes to the database to speed up the access, at 1200least theses should be added to slapd.conf. 1201 1202@example 1203index objectClass eq 1204index cn eq,sub,pres 1205index uid eq,sub,pres 1206index displayName eq,sub,pres 1207index krb5PrincipalName eq 1208@end example 1209 1210@end itemize 1211 1212@subsection smbk5pwd overlay 1213 1214The smbk5pwd overlay, updates the krb5Key and krb5KeyVersionNumber 1215appropriately when it receives an LDAP Password change Extended 1216Operation: 1217 1218@url{http://www.openldap.org/devel/cvsweb.cgi/contrib/slapd-modules/smbk5pwd/README?hideattic=1&sortbydate=0} 1219 1220@subsection Troubleshooting guide 1221 1222@url{https://sec.miljovern.no/bin/view/Info/TroubleshootingGuide} 1223 1224 1225@subsection Using Samba LDAP password database 1226@cindex Samba 1227 1228@c @node Using Samba LDAP password database, Providing Kerberos credentials to servers and programs, Using LDAP to store the database, Setting up a realm 1229@c @section Using Samba LDAP password database 1230 1231The Samba domain and the Kerberos realm can have different names since 1232arcfour's string to key functions principal/realm independent. So now 1233will be your first and only chance name your Kerberos realm without 1234needing to deal with old configuration files. 1235 1236First, you should set up Samba and get that working with LDAP backend. 1237 1238Now you can proceed as in @xref{Using LDAP to store the database}. 1239Heimdal will pick up the Samba LDAP entries if they are in the same 1240search space as the Kerberos entries. 1241 1242@node Providing Kerberos credentials to servers and programs, Setting up PK-INIT, Using LDAP to store the database, Setting up a realm 1243@section Providing Kerberos credentials to servers and programs 1244 1245Some services require Kerberos credentials when they start to make 1246connections to other services or need to use them when they have started. 1247 1248The easiest way to get tickets for a service is to store the key in a 1249keytab. Both ktutil get and kadmin ext can be used to get a 1250keytab. ktutil get is better in that way it changes the key/password 1251for the user. This is also the problem with ktutil. If ktutil is used 1252for the same service principal on several hosts, they keytab will only 1253be useful on the last host. In that case, run the extract command on 1254one host and then securely copy the keytab around to all other hosts 1255that need it. 1256 1257@example 1258host# ktutil -k /etc/krb5-service.keytab \ 1259 get -p lha/admin@@EXAMPLE.ORG service-principal@@EXAMPLE.ORG 1260lha/admin@@EXAMPLE.ORG's Password: 1261@end example 1262 1263To get a Kerberos credential file for the service, use kinit in the 1264@kbd{--keytab} mode. This will not ask for a password but instead fetch the 1265key from the keytab. 1266 1267@example 1268service@@host$ kinit --cache=/var/run/service_krb5_cache \ 1269 --keytab=/etc/krb5-service.keytab \ 1270 service-principal@@EXAMPLE.ORG 1271@end example 1272 1273Long running services might need credentials longer then the 1274expiration time of the tickets. kinit can run in a mode that refreshes 1275the tickets before they expire. This is useful for services that write 1276into AFS and other distributed file systems using Kerberos. To run the 1277long running script, just append the program and arguments (if any) 1278after the principal. kinit will stop refreshing credentials and remove 1279the credentials when the script-to-start-service exits. 1280 1281@example 1282service@@host$ kinit --cache=/var/run/service_krb5_cache \ 1283 --keytab=/etc/krb5-service.keytab \ 1284 service-principal@@EXAMPLE.ORG \ 1285 script-to-start-service argument1 argument2 1286@end example 1287 1288 1289@node Setting up PK-INIT, Debugging Kerberos problems, Providing Kerberos credentials to servers and programs, Setting up a realm 1290@section Setting up PK-INIT 1291 1292PK-INIT leverages an existing PKI (public key infrastructure), using 1293certificates to get the initial ticket (usually the krbtgt 1294ticket-granting ticket). 1295 1296To use PK-INIT you must first have a PKI. If you don't have one, it is 1297time to create it. You should first read the whole chapter of the 1298document to see the requirements imposed on the CA software. 1299 1300A mapping between the PKI certificate and what principals that 1301certificate is allowed to use must exist. There are several ways to do 1302this. The administrator can use a configuration file, store the 1303principal in the SubjectAltName extension of the certificate, or store 1304the mapping in the principals entry in the kerberos database. 1305 1306@section Certificates 1307 1308This section documents the requirements on the KDC and client 1309certificates and the format used in the id-pkinit-san OtherName 1310extention. 1311 1312@subsection KDC certificate 1313 1314The certificate for the KDC has serveral requirements. 1315 1316First, the certificate should have an Extended Key Usage (EKU) 1317id-pkkdcekuoid (1.3.6.1.5.2.3.5) set. Second, there must be a 1318subjectAltName otherName using OID id-pkinit-san (1.3.6.1.5.2.2) in 1319the type field and a DER encoded KRB5PrincipalName that matches the 1320name of the TGS of the target realm. Also, if the certificate has a 1321nameConstraints extention with a Generalname with dNSName or iPAdress, 1322it must match the hostname or adress of the KDC. 1323 1324The client is not required by the standard to check the server 1325certificate for this information if the client has external 1326information confirming which certificate the KDC is supposed to be 1327using. However, adding this information to the KDC certificate removes 1328the need to specially configure the client to recognize the KDC 1329certificate. 1330 1331Remember that if the client would accept any certificate as the KDC's 1332certificate, the client could be fooled into trusting something that 1333isn't a KDC and thus expose the user to giving away information (like 1334a password or other private information) that it is supposed to keep 1335secret. 1336 1337@subsection Client certificate 1338 1339The client certificate may need to have a EKU id-pkekuoid 1340(1.3.6.1.5.2.3.4) set depending on the certifiate on the KDC. 1341 1342It possible to store the principal (if allowed by the KDC) in the 1343certificate and thus delegate responsibility to do the mapping between 1344certificates and principals to the CA. 1345 1346This behavior is controlled by KDC configuration option: 1347 1348@example 1349[kdc] 1350 pkinit_principal_in_certificate = yes 1351@end example 1352 1353@subsubsection Using KRB5PrincipalName in id-pkinit-san 1354 1355The OtherName extention in the GeneralName is used to do the mapping 1356between certificate and principal. For the KDC certificate, this 1357stores the krbtgt principal name for that KDC. For the client 1358certificate, this stores the principal for which that certificate is 1359allowed to get tickets. 1360 1361The principal is stored in a SubjectAltName in the certificate using 1362OtherName. The OID in the type is id-pkinit-san. 1363 1364@example 1365id-pkinit-san OBJECT IDENTIFIER ::= @{ iso (1) org (3) dod (6) 1366internet (1) security (5) kerberosv5 (2) 2 @} 1367@end example 1368 1369The data part of the OtherName is filled with the following DER 1370encoded ASN.1 structure: 1371 1372@example 1373KRB5PrincipalName ::= SEQUENCE @{ 1374 realm [0] Realm, 1375 principalName [1] PrincipalName 1376@} 1377@end example 1378 1379where Realm and PrincipalName is defined by the Kerberos ASN.1 1380specification. 1381 1382@section Naming certificate using hx509 1383 1384hx509 is the X.509 software used in Heimdal to handle 1385certificates. hx509 supports several different syntaxes for specifying 1386certificate files or formats. Several formats may be used: PEM, 1387certificates embedded in PKCS#12 files, certificates embedded in 1388PKCS#11 devices, and raw DER encoded certificates. 1389 1390Those formats may be specified as follows: 1391 1392@table @asis 1393 1394@item DIR: 1395 1396DIR specifies a directory which contains certificates in the DER or 1397PEM format. 1398 1399The main feature of DIR is that the directory is read on demand when 1400iterating over certificates. This allows applications, in some 1401situations, to avoid having to store all certificates in memory. It's 1402very useful for tests that iterate over large numbers of certificates. 1403 1404The syntax is: 1405 1406@example 1407DIR:/path/to/der/files 1408@end example 1409 1410@item FILE: 1411 1412FILE: specifies a file that contains a certificate or private key. 1413The file can be either a PEM (openssl) file or a raw DER encoded 1414certificate. If it's a PEM file, it can contain several keys and 1415certificates and the code will try to match the private key and 1416certificate together. Multiple files may be specified, separated by 1417commas. 1418 1419It's useful to have one PEM file that contains all the trust anchors. 1420 1421The syntax is: 1422 1423@example 1424FILE:certificate.pem,private-key.key,other-cert.pem,.... 1425@end example 1426 1427@item PKCS11: 1428 1429PKCS11: is used to handle smartcards via PKCS#11 drivers, such as 1430soft-token, opensc, or muscle. The argument specifies a shared object 1431that implements the PKCS#11 API. The default is to use all slots on 1432the device/token. 1433 1434The syntax is: 1435 1436@example 1437PKCS11:shared-object.so 1438@end example 1439 1440@item PKCS12: 1441 1442PKCS12: is used to handle PKCS#12 files. PKCS#12 files commonly have 1443the extension pfx or p12. 1444 1445The syntax is: 1446 1447@example 1448PKCS12:/path/to/file.pfx 1449@end example 1450 1451@end table 1452 1453@section Configure the Kerberos software 1454 1455First configure the client's trust anchors and what parameters to 1456verify. See the subsections below for how to do that. Then, you can 1457use kinit to get yourself tickets. For example: 1458 1459@example 1460$ kinit -C FILE:$HOME/.certs/lha.crt,$HOME/.certs/lha.key lha@@EXAMPLE.ORG 1461Enter your private key passphrase: 1462: lha@@nutcracker ; klist 1463Credentials cache: FILE:/tmp/krb5cc_19100a 1464 Principal: lha@@EXAMPLE.ORG 1465 1466 Issued Expires Principal 1467Apr 20 02:08:08 Apr 20 12:08:08 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG 1468@end example 1469 1470Using PKCS#11 it can look like this instead: 1471 1472@example 1473$ kinit -C PKCS11:/usr/heimdal/lib/hx509.so lha@@EXAMPLE.ORG 1474PIN code for SoftToken (slot): 1475$ klist 1476Credentials cache: API:4 1477 Principal: lha@@EXAMPLE.ORG 1478 1479 Issued Expires Principal 1480Mar 26 23:40:10 Mar 27 09:40:10 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG 1481@end example 1482 1483TODO: Write about the KDC. 1484 1485@section Configure the client 1486 1487@example 1488[appdefaults] 1489 pkinit_anchors = FILE:/path/to/trust-anchors.pem 1490 1491[realms] 1492 EXAMPLE.COM = @{ 1493 pkinit_require_eku = true 1494 pkinit_require_krbtgt_otherName = true 1495 pkinit_win2k = no 1496 pkinit_win2k_require_binding = yes 1497 @} 1498 1499@end example 1500 1501@section Configure the KDC 1502 1503@example 1504[kdc] 1505 enable-pkinit = yes 1506 pkinit_identity = FILE:/secure/kdc.crt,/secure/kdc.key 1507 pkinit_anchors = FILE:/path/to/trust-anchors.pem 1508 pkinit_pool = PKCS12:/path/to/useful-intermediate-certs.pfx 1509 pkinit_pool = FILE:/path/to/other-useful-intermediate-certs.pem 1510 pkinit_allow_proxy_certificate = no 1511 pkinit_win2k_require_binding = yes 1512 pkinit_principal_in_certificate = no 1513@end example 1514 1515@subsection Using pki-mapping file 1516 1517Note that the file name is space sensitive. 1518 1519@example 1520# cat /var/heimdal/pki-mapping 1521# comments starts with # 1522lha@@EXAMPLE.ORG:C=SE,O=Stockholm universitet,CN=Love,UID=lha 1523lha@@EXAMPLE.ORG:CN=Love,UID=lha 1524@end example 1525 1526@subsection Using the Kerberos database 1527 1528@section Use hxtool to create certificates 1529 1530@subsection Generate certificates 1531 1532First, you need to generate a CA certificate. This example creates a 1533CA certificate that will be valid for 10 years. 1534 1535You need to change --subject in the command below to something 1536appropriate for your site. 1537 1538@example 1539hxtool issue-certificate \ 1540 --self-signed \ 1541 --issue-ca \ 1542 --generate-key=rsa \ 1543 --subject="CN=CA,DC=test,DC=h5l,DC=se" \ 1544 --lifetime=10years \ 1545 --certificate="FILE:ca.pem" 1546@end example 1547 1548The KDC needs to have a certificate, so generate a certificate of the 1549type ``pkinit-kdc'' and set the PK-INIT specifial SubjectAltName to the 1550name of the krbtgt of the realm. 1551 1552You need to change --subject and --pk-init-principal in the command 1553below to something appropriate for your site. 1554 1555@example 1556hxtool issue-certificate \ 1557 --ca-certificate=FILE:ca.pem \ 1558 --generate-key=rsa \ 1559 --type="pkinit-kdc" \ 1560 --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \ 1561 --subject="uid=kdc,DC=test,DC=h5l,DC=se" \ 1562 --certificate="FILE:kdc.pem" 1563@end example 1564 1565The users also needs to have certificates. For your first client, 1566generate a certificate of type ``pkinit-client''. The client doesn't 1567need to have the PK-INIT SubjectAltName set; you can have the Subject 1568DN in the ACL file (pki-mapping) instead. 1569 1570You need to change --subject and --pk-init-principal in the command 1571below to something appropriate for your site. You can omit 1572--pk-init-principal if you're going to use the ACL file instead. 1573 1574@example 1575hxtool issue-certificate \ 1576 --ca-certificate=FILE:ca.pem \ 1577 --generate-key=rsa \ 1578 --type="pkinit-client" \ 1579 --pk-init-principal="lha@@TEST.H5L.SE" \ 1580 --subject="uid=lha,DC=test,DC=h5l,DC=se" \ 1581 --certificate="FILE:user.pem" 1582@end example 1583 1584@subsection Validate the certificate 1585 1586hxtool also contains a tool that will validate certificates according 1587to rules from the PKIX document. These checks are not complete, but 1588they provide a good test of whether you got all of the basic bits 1589right in your certificates. 1590 1591@example 1592hxtool validate FILE:user.pem 1593@end example 1594 1595@section Use OpenSSL to create certificates 1596 1597This section tries to give the CA owners hints how to create 1598certificates using OpenSSL (or CA software based on OpenSSL). 1599 1600@subsection Using OpenSSL to create certificates with krb5PrincipalName 1601 1602To make OpenSSL create certificates with krb5PrincipalName, use an 1603@file{openssl.cnf} as described below. To see a complete example of 1604creating client and KDC certificates, see the test-data generation 1605script @file{lib/hx509/data/gen-req.sh} in the source-tree. The 1606certicates it creates are used to test the PK-INIT functionality in 1607@file{tests/kdc/check-kdc.in}. 1608 1609To use this example you have to use OpenSSL 0.9.8a or later. 1610 1611@example 1612 1613[user_certificate] 1614subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:princ_name 1615 1616[princ_name] 1617realm = EXP:0, GeneralString:MY.REALM 1618principal_name = EXP:1, SEQUENCE:principal_seq 1619 1620[principal_seq] 1621name_type = EXP:0, INTEGER:1 1622name_string = EXP:1, SEQUENCE:principals 1623 1624[principals] 1625princ1 = GeneralString:userid 1626 1627@end example 1628 1629Command usage: 1630 1631@example 1632openssl x509 -extensions user_certificate 1633openssl ca -extensions user_certificate 1634@end example 1635 1636 1637@c --- ms certificate 1638@c 1639@c [ new_oids ] 1640@c msCertificateTemplateName = 1.3.6.1.4.1.311.20.2 1641@c 1642@c 1643@c [ req_smartcard ] 1644@c keyUsage = digitalSignature, keyEncipherment 1645@c extendedKeyUsage = msSmartcardLogin, clientAuth 1646@c msCertificateTemplateName = ASN1:BMP:SmartcardLogon 1647@c subjectAltName = otherName:msUPN;UTF8:lukeh@dsg.padl.com 1648@c #subjectAltName = email:copy 1649 1650 1651@section Using PK-INIT with Windows 1652 1653@subsection Client configration 1654 1655Clients using a Windows KDC with PK-INIT need configuration since 1656windows uses pre-standard format and this can't be autodetected. 1657 1658The pkinit_win2k_require_binding option requires the reply for the KDC 1659to be of the new, secure, type that binds the request to 1660reply. Before, clients could fake the reply from the KDC. To use this 1661option you have to apply a fix from Microsoft. 1662 1663@example 1664[realms] 1665 MY.MS.REALM = @{ 1666 pkinit_win2k = yes 1667 pkinit_win2k_require_binding = no 1668 @} 1669@end example 1670 1671@subsection Certificates 1672 1673The client certificates need to have the extended keyusage ``Microsoft 1674Smartcardlogin'' (openssl has the OID shortname msSmartcardLogin). 1675 1676See Microsoft Knowledge Base Article - 281245 ``Guidelines for Enabling 1677Smart Card Logon with Third-Party Certification Authorities'' for a 1678more extensive description of how set setup an external CA so that it 1679includes all the information required to make a Windows KDC happy. 1680 1681@subsection Configure Windows 2000 CA 1682 1683To enable Microsoft Smartcardlogin for certificates in your Windows 16842000 CA, you want to look at Microsoft Knowledge Base Article - 313274 1685``HOW TO: Configure a Certification Authority to Issue Smart Card 1686Certificates in Windows''. 1687 1688@node Debugging Kerberos problems, , Setting up PK-INIT, Setting up a realm 1689@section Debugging Kerberos problems 1690 1691To debug Kerberos client and server problems you can enable debug 1692traceing by adding the following to @file{/etc/krb5,conf}. Note that the 1693trace logging is sparse at the moment, but will continue to improve. 1694 1695@example 1696[logging] 1697 libkrb5 = 0-/SYSLOG: 1698@end example 1699 1700 1701 1702 1703