1ae771770SStanislav Sedov@c $Id$ 25e9cd1aeSAssar Westerlund 3c19800e8SDoug Rabson@node Setting up a realm, Applications, Building and Installing, Top 45e9cd1aeSAssar Westerlund 5b528cefcSMark Murray@chapter Setting up a realm 6b528cefcSMark Murray 7b528cefcSMark MurrayA 8b528cefcSMark Murray@cindex realm 9b528cefcSMark Murrayrealm is an administrative domain. The name of a Kerberos realm is 10b528cefcSMark Murrayusually the Internet domain name in uppercase. Call your realm the same 11b528cefcSMark Murrayas your Internet domain name if you do not have strong reasons for not 12b528cefcSMark Murraydoing so. It will make life easier for you and everyone else. 13b528cefcSMark Murray 14c19800e8SDoug Rabson@menu 15c19800e8SDoug Rabson* Configuration file:: 16c19800e8SDoug Rabson* Creating the database:: 17c19800e8SDoug Rabson* Modifying the database:: 18c19800e8SDoug Rabson* Checking the setup:: 19c19800e8SDoug Rabson* keytabs:: 20c19800e8SDoug Rabson* Remote administration:: 21c19800e8SDoug Rabson* Password changing:: 22c19800e8SDoug Rabson* Testing clients and servers:: 23c19800e8SDoug Rabson* Slave Servers:: 24c19800e8SDoug Rabson* Incremental propagation:: 25c19800e8SDoug Rabson* Encryption types and salting:: 26ae771770SStanislav Sedov* Credential cache server - KCM:: 27c19800e8SDoug Rabson* Cross realm:: 28c19800e8SDoug Rabson* Transit policy:: 29c19800e8SDoug Rabson* Setting up DNS:: 30c19800e8SDoug Rabson* Using LDAP to store the database:: 31c19800e8SDoug Rabson* Providing Kerberos credentials to servers and programs:: 32c19800e8SDoug Rabson* Setting up PK-INIT:: 33ae771770SStanislav Sedov* Debugging Kerberos problems:: 34c19800e8SDoug Rabson@end menu 35c19800e8SDoug Rabson 365e9cd1aeSAssar Westerlund@node Configuration file, Creating the database, Setting up a realm, Setting up a realm 37b528cefcSMark Murray@section Configuration file 38b528cefcSMark Murray 39b528cefcSMark MurrayTo setup a realm you will first have to create a configuration file: 40b528cefcSMark Murray@file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many 41b528cefcSMark Murrayconfiguration options, some of which are described here. 42b528cefcSMark Murray 43b528cefcSMark MurrayThere is a sample @file{krb5.conf} supplied with the distribution. 44b528cefcSMark Murray 45b528cefcSMark MurrayThe configuration file is a hierarchical structure consisting of 46b528cefcSMark Murraysections, each containing a list of bindings (either variable 47b528cefcSMark Murrayassignments or subsections). A section starts with 48c19800e8SDoug Rabson@samp{[@samp{section-name}]}. A binding consists of a left hand side, an equal sign 49b528cefcSMark Murray(@samp{=}) and a right hand side (the left hand side tag must be 50c19800e8SDoug Rabsonseparated from the equal sign with some whitespace). Subsections have a 51c19800e8SDoug Rabson@samp{@{} as the first non-whitespace character after the equal sign. All 52b528cefcSMark Murrayother bindings are treated as variable assignments. The value of a 53b528cefcSMark Murrayvariable extends to the end of the line. 54b528cefcSMark Murray 55b528cefcSMark Murray@example 56b528cefcSMark Murray[section1] 57b528cefcSMark Murray a-subsection = @{ 58b528cefcSMark Murray var = value1 59b528cefcSMark Murray other-var = value with @{@} 60b528cefcSMark Murray sub-sub-section = @{ 61b528cefcSMark Murray var = 123 62b528cefcSMark Murray @} 63b528cefcSMark Murray @} 64b528cefcSMark Murray var = some other value 65b528cefcSMark Murray[section2] 66b528cefcSMark Murray var = yet another value 67b528cefcSMark Murray@end example 68b528cefcSMark Murray 69b528cefcSMark MurrayIn this manual, names of sections and bindings will be given as strings 70b528cefcSMark Murrayseparated by slashes (@samp{/}). The @samp{other-var} variable will thus 71b528cefcSMark Murraybe @samp{section1/a-subsection/other-var}. 72b528cefcSMark Murray 731c43270aSJacques VidrineFor in-depth information about the contents of the configuration file, refer to 74b528cefcSMark Murraythe @file{krb5.conf} manual page. Some of the more important sections 75b528cefcSMark Murrayare briefly described here. 76b528cefcSMark Murray 77b528cefcSMark MurrayThe @samp{libdefaults} section contains a list of library configuration 781c43270aSJacques Vidrineparameters, such as the default realm and the timeout for KDC 79b528cefcSMark Murrayresponses. The @samp{realms} section contains information about specific 80c19800e8SDoug Rabsonrealms, such as where they hide their KDC@. This section serves the same 81b528cefcSMark Murraypurpose as the Kerberos 4 @file{krb.conf} file, but can contain more 82b528cefcSMark Murrayinformation. Finally the @samp{domain_realm} section contains a list of 83b528cefcSMark Murraymappings from domains to realms, equivalent to the Kerberos 4 84b528cefcSMark Murray@file{krb.realms} file. 85b528cefcSMark Murray 861c43270aSJacques VidrineTo continue with the realm setup, you will have to create a configuration file, 87b528cefcSMark Murraywith contents similar to the following. 88b528cefcSMark Murray 89b528cefcSMark Murray@example 90b528cefcSMark Murray[libdefaults] 91b528cefcSMark Murray default_realm = MY.REALM 92b528cefcSMark Murray[realms] 93b528cefcSMark Murray MY.REALM = @{ 941c43270aSJacques Vidrine kdc = my.kdc my.slave.kdc 951c43270aSJacques Vidrine kdc = my.third.kdc 96ae771770SStanislav Sedov kdc = 130.237.237.17 97ae771770SStanislav Sedov kdc = [2001:6b0:1:ea::100]:88 98b528cefcSMark Murray @} 99b528cefcSMark Murray[domain_realm] 100b528cefcSMark Murray .my.domain = MY.REALM 101b528cefcSMark Murray 102b528cefcSMark Murray@end example 103b528cefcSMark Murray 104b528cefcSMark MurrayIf you use a realm name equal to your domain name, you can omit the 105c19800e8SDoug Rabson@samp{libdefaults}, and @samp{domain_realm}, sections. If you have a DNS 106c19800e8SDoug RabsonSRV-record for your realm, or your Kerberos server has DNS CNAME 107b528cefcSMark Murray@samp{kerberos.my.realm}, you can omit the @samp{realms} section too. 108b528cefcSMark Murray 109ae771770SStanislav Sedov@cindex KRB5_CONFIG 110ae771770SStanislav SedovIf you want to use a different configuration file then the default you 111ae771770SStanislav Sedovcan point a file with the enviroment variable @samp{KRB5_CONFIG}. 112ae771770SStanislav Sedov 113ae771770SStanislav Sedov@example 114ae771770SStanislav Sedovenv KRB5_CONFIG=$HOME/etc/krb5.conf kinit user@@REALM 115ae771770SStanislav Sedov@end example 116ae771770SStanislav Sedov 117c19800e8SDoug Rabson@node Creating the database, Modifying the database, Configuration file, Setting up a realm 118b528cefcSMark Murray@section Creating the database 119b528cefcSMark Murray 1201c43270aSJacques VidrineThe database library will look for the database in the directory 121c19800e8SDoug Rabson@file{@value{dbdir}}, so you should probably create that directory. 122c19800e8SDoug RabsonMake sure the directory has restrictive permissions. 1231c43270aSJacques Vidrine 1241c43270aSJacques Vidrine@example 1251c43270aSJacques Vidrine# mkdir /var/heimdal 1261c43270aSJacques Vidrine@end example 127b528cefcSMark Murray 128b528cefcSMark MurrayThe keys of all the principals are stored in the database. If you 129b528cefcSMark Murraychoose to, these can be encrypted with a master key. You do not have to 130b528cefcSMark Murrayremember this key (or password), but just to enter it once and it will 131b528cefcSMark Murraybe stored in a file (@file{/var/heimdal/m-key}). If you want to have a 132b528cefcSMark Murraymaster key, run @samp{kstash} to create this master key: 133b528cefcSMark Murray 134b528cefcSMark Murray@example 135b528cefcSMark Murray# kstash 136b528cefcSMark MurrayMaster key: 137b528cefcSMark MurrayVerifying password - Master key: 138b528cefcSMark Murray@end example 139b528cefcSMark Murray 140c19800e8SDoug RabsonIf you want to generate a random master key you can use the 141c19800e8SDoug Rabson@kbd{--random-key} flag to kstash. This will make sure you have a good key 142c19800e8SDoug Rabsonon which attackers can't do a dictionary attack. 143c19800e8SDoug Rabson 144c19800e8SDoug RabsonIf you have a master key, make sure you make a backup of your master 145c19800e8SDoug Rabsonkey file; without it backups of the database are of no use. 146c19800e8SDoug Rabson 147c19800e8SDoug RabsonTo initialise the database use the @command{kadmin} program, with the 148c19800e8SDoug Rabson@kbd{-l} option (to enable local database mode). First issue a 149b528cefcSMark Murray@kbd{init MY.REALM} command. This will create the database and insert 150b528cefcSMark Murraydefault principals for that realm. You can have more than one realm in 151b528cefcSMark Murrayone database, so @samp{init} does not destroy any old database. 152b528cefcSMark Murray 153b528cefcSMark MurrayBefore creating the database, @samp{init} will ask you some questions 154c19800e8SDoug Rabsonabout maximum ticket lifetimes. 155b528cefcSMark Murray 156b528cefcSMark MurrayAfter creating the database you should probably add yourself to it. You 157b528cefcSMark Murraydo this with the @samp{add} command. It takes as argument the name of a 158b528cefcSMark Murrayprincipal. The principal should contain a realm, so if you haven't set up 159b528cefcSMark Murraya default realm, you will need to explicitly include the realm. 160b528cefcSMark Murray 161b528cefcSMark Murray@example 162b528cefcSMark Murray# kadmin -l 163b528cefcSMark Murraykadmin> init MY.REALM 164b528cefcSMark MurrayRealm max ticket life [unlimited]: 165b528cefcSMark MurrayRealm max renewable ticket life [unlimited]: 166b528cefcSMark Murraykadmin> add me 167b528cefcSMark MurrayMax ticket life [unlimited]: 168b528cefcSMark MurrayMax renewable life [unlimited]: 169b528cefcSMark MurrayAttributes []: 170b528cefcSMark MurrayPassword: 171b528cefcSMark MurrayVerifying password - Password: 172b528cefcSMark Murray@end example 173b528cefcSMark Murray 174b528cefcSMark MurrayNow start the KDC and try getting a ticket. 175b528cefcSMark Murray 176b528cefcSMark Murray@example 177b528cefcSMark Murray# kdc & 178b528cefcSMark Murray# kinit me 179b528cefcSMark Murrayme@@MY.REALMS's Password: 180b528cefcSMark Murray# klist 181b528cefcSMark MurrayCredentials cache: /tmp/krb5cc_0 182b528cefcSMark Murray Principal: me@@MY.REALM 183b528cefcSMark Murray 184b528cefcSMark Murray Issued Expires Principal 185b528cefcSMark MurrayAug 25 07:25:55 Aug 25 17:25:55 krbtgt/MY.REALM@@MY.REALM 186b528cefcSMark Murray@end example 187b528cefcSMark Murray 188b528cefcSMark MurrayIf you are curious you can use the @samp{dump} command to list all the 189b528cefcSMark Murrayentries in the database. It should look something similar to the 190b528cefcSMark Murrayfollowing example (note that the entries here are truncated for 191b528cefcSMark Murraytypographical reasons): 192b528cefcSMark Murray 193b528cefcSMark Murray@smallexample 194b528cefcSMark Murraykadmin> dump 195b528cefcSMark Murrayme@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ... 196b528cefcSMark Murraykadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ... 197b528cefcSMark Murraykrbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ... 198b528cefcSMark Murraykadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ... 199b528cefcSMark Murray@end smallexample 200b528cefcSMark Murray 201c19800e8SDoug Rabson@node Modifying the database, Checking the setup, Creating the database, Setting up a realm 202c19800e8SDoug Rabson@section Modifying the database 203c19800e8SDoug Rabson 204c19800e8SDoug RabsonAll modifications of principals are done with with kadmin. 205c19800e8SDoug Rabson 206c19800e8SDoug RabsonA principal has several attributes and lifetimes associated with it. 207c19800e8SDoug Rabson 208c19800e8SDoug RabsonPrincipals are added, renamed, modified, and deleted with the kadmin 209c19800e8SDoug Rabsoncommands @samp{add}, @samp{rename}, @samp{modify}, @samp{delete}. 210c19800e8SDoug RabsonBoth interactive editing and command line flags can be used (use --help 211c19800e8SDoug Rabsonto list the available options). 212c19800e8SDoug Rabson 213c19800e8SDoug RabsonThere are different kinds of types for the fields in the database; 214c19800e8SDoug Rabsonattributes, absolute time times and relative times. 215c19800e8SDoug Rabson 216c19800e8SDoug Rabson@subsection Attributes 217c19800e8SDoug Rabson 218c19800e8SDoug RabsonWhen doing interactive editing, attributes are listed with @samp{?}. 219c19800e8SDoug Rabson 220c19800e8SDoug RabsonThe attributes are given in a comma (@samp{,}) separated list. 221c19800e8SDoug RabsonAttributes are removed from the list by prefixing them with @samp{-}. 222c19800e8SDoug Rabson 223c19800e8SDoug Rabson@smallexample 224c19800e8SDoug Rabsonkadmin> modify me 225c19800e8SDoug RabsonMax ticket life [1 day]: 226c19800e8SDoug RabsonMax renewable life [1 week]: 227c19800e8SDoug RabsonPrincipal expiration time [never]: 228c19800e8SDoug RabsonPassword expiration time [never]: 229c19800e8SDoug RabsonAttributes [disallow-renewable]: requires-pre-auth,-disallow-renewable 230c19800e8SDoug Rabsonkadmin> get me 231c19800e8SDoug Rabson Principal: me@@MY.REALM 232c19800e8SDoug Rabson[...] 233c19800e8SDoug Rabson Attributes: requires-pre-auth 234c19800e8SDoug Rabson@end smallexample 235c19800e8SDoug Rabson 236c19800e8SDoug Rabson@subsection Absolute times 237c19800e8SDoug Rabson 238c19800e8SDoug RabsonThe format for absolute times are any of the following: 239c19800e8SDoug Rabson 240c19800e8SDoug Rabson@smallexample 241c19800e8SDoug Rabsonnever 242c19800e8SDoug Rabsonnow 243c19800e8SDoug RabsonYYYY-mm-dd 244c19800e8SDoug RabsonYYYY-mm-dd HH:MM:SS 245c19800e8SDoug Rabson@end smallexample 246c19800e8SDoug Rabson 247c19800e8SDoug Rabson 248c19800e8SDoug Rabson@subsection Relative times 249c19800e8SDoug Rabson 250c19800e8SDoug RabsonThe format for relative times are any of the following combined: 251c19800e8SDoug Rabson 252c19800e8SDoug Rabson@smallexample 253c19800e8SDoug RabsonN year 254c19800e8SDoug RabsonM month 255c19800e8SDoug RabsonO day 256c19800e8SDoug RabsonP hour 257c19800e8SDoug RabsonQ minute 258c19800e8SDoug RabsonR second 259c19800e8SDoug Rabson@end smallexample 260c19800e8SDoug Rabson 261c19800e8SDoug Rabson@c Describe more of kadmin commands here... 262c19800e8SDoug Rabson 263c19800e8SDoug Rabson@node Checking the setup, keytabs, Modifying the database, Setting up a realm 264c19800e8SDoug Rabson@section Checking the setup 265c19800e8SDoug Rabson 266c19800e8SDoug RabsonThere are two tools that can check the consistency of the Kerberos 267c19800e8SDoug Rabsonconfiguration file and the Kerberos database. 268c19800e8SDoug Rabson 269c19800e8SDoug RabsonThe Kerberos configuration file is checked using 270c19800e8SDoug Rabson@command{verify_krb5_conf}. The tool checks for common errors, but 271c19800e8SDoug Rabsoncommonly there are several uncommon configuration entries that are 272c19800e8SDoug Rabsonnever added to the tool and thus generates ``unknown entry'' warnings. 273c19800e8SDoug RabsonThis is usually nothing to worry about. 274c19800e8SDoug Rabson 275c19800e8SDoug RabsonThe database check is built into the kadmin tool. It will check for 276c19800e8SDoug Rabsoncommon configuration error that will cause problems later. Common 277c19800e8SDoug Rabsoncheck are for existence and flags on important principals. The 278c19800e8SDoug Rabsondatabase check by run by the following command : 279c19800e8SDoug Rabson 280c19800e8SDoug Rabson@example 281ae771770SStanislav Sedovkadmin -l check REALM.EXAMPLE.ORG 282c19800e8SDoug Rabson@end example 283c19800e8SDoug Rabson 284*cf771f22SStanislav Sedov@node keytabs, Remote administration, Checking the setup, Setting up a realm 285b528cefcSMark Murray@section keytabs 286b528cefcSMark Murray 287c19800e8SDoug RabsonTo extract a service ticket from the database and put it in a keytab, you 288ae771770SStanislav Sedovneed to first create the principal in the database with @samp{add} 2895e9cd1aeSAssar Westerlund(using the @kbd{--random-key} flag to get a random key) and then 290b528cefcSMark Murrayextract it with @samp{ext_keytab}. 291b528cefcSMark Murray 292b528cefcSMark Murray@example 2935e9cd1aeSAssar Westerlundkadmin> add --random-key host/my.host.name 294b528cefcSMark MurrayMax ticket life [unlimited]: 295b528cefcSMark MurrayMax renewable life [unlimited]: 296b528cefcSMark MurrayAttributes []: 297b528cefcSMark Murraykadmin> ext host/my.host.name 298c19800e8SDoug Rabsonkadmin> exit 299b528cefcSMark Murray# ktutil list 300b528cefcSMark MurrayVersion Type Principal 301b528cefcSMark Murray 1 des-cbc-md5 host/my.host.name@@MY.REALM 302b528cefcSMark Murray 1 des-cbc-md4 host/my.host.name@@MY.REALM 303b528cefcSMark Murray 1 des-cbc-crc host/my.host.name@@MY.REALM 304b528cefcSMark Murray 1 des3-cbc-sha1 host/my.host.name@@MY.REALM 305b528cefcSMark Murray@end example 306b528cefcSMark Murray 307*cf771f22SStanislav Sedov@node Remote administration, Password changing, keytabs, Setting up a realm 308b528cefcSMark Murray@section Remote administration 309b528cefcSMark Murray 310c19800e8SDoug RabsonThe administration server, @command{kadmind}, can be started by 311c19800e8SDoug Rabson@command{inetd} (which isn't recommended) or run as a normal daemon. If you 312c19800e8SDoug Rabsonwant to start it from @command{inetd} you should add a line similar to the 3135e9cd1aeSAssar Westerlundone below to your @file{/etc/inetd.conf}. 314b528cefcSMark Murray 315b528cefcSMark Murray@example 316b528cefcSMark Murraykerberos-adm stream tcp nowait root /usr/heimdal/libexec/kadmind kadmind 317b528cefcSMark Murray@end example 318b528cefcSMark Murray 319b528cefcSMark MurrayYou might need to add @samp{kerberos-adm} to your @file{/etc/services} 320c19800e8SDoug Rabsonas @samp{749/tcp}. 321b528cefcSMark Murray 322c19800e8SDoug RabsonAccess to the administration server is controlled by an ACL file, 323c19800e8SDoug Rabson(default @file{/var/heimdal/kadmind.acl}.) The file has the following 324c19800e8SDoug Rabsonsyntax: 325b528cefcSMark Murray@smallexample 3265e9cd1aeSAssar Westerlundprincipal [priv1,priv2,...] [glob-pattern] 327b528cefcSMark Murray@end smallexample 328b528cefcSMark Murray 329c19800e8SDoug RabsonThe matching is from top to bottom for matching principals (and if given, 330c19800e8SDoug Rabsonglob-pattern). When there is a match, the access rights of that line are 331c19800e8SDoug Rabsonapplied. 3324137ff4cSJacques Vidrine 333b528cefcSMark MurrayThe privileges you can assign to a principal are: @samp{add}, 334b528cefcSMark Murray@samp{change-password} (or @samp{cpw} for short), @samp{delete}, 335b528cefcSMark Murray@samp{get}, @samp{list}, and @samp{modify}, or the special privilege 336c19800e8SDoug Rabson@samp{all}. All of these roughly correspond to the different commands 337c19800e8SDoug Rabsonin @command{kadmin}. 338b528cefcSMark Murray 339c19800e8SDoug RabsonIf a @var{glob-pattern} is given on a line, it restricts the access 340c19800e8SDoug Rabsonrights for the principal to only apply for subjects that match the 341c19800e8SDoug Rabsonpattern. The patterns are of the same type as those used in shell 342c19800e8SDoug Rabsonglobbing, see @url{none,,fnmatch(3)}. 3435e9cd1aeSAssar Westerlund 3445e9cd1aeSAssar WesterlundIn the example below @samp{lha/admin} can change every principal in the 3455e9cd1aeSAssar Westerlunddatabase. @samp{jimmy/admin} can only modify principals that belong to 3465e9cd1aeSAssar Westerlundthe realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the 3475e9cd1aeSAssar Westerlundhelp desk, so he should only be able to change the passwords for single 3485e9cd1aeSAssar Westerlundcomponent principals (ordinary users). He will not be able to change any 3495e9cd1aeSAssar Westerlund@samp{/admin} principal. 3505e9cd1aeSAssar Westerlund 3515e9cd1aeSAssar Westerlund@example 3525e9cd1aeSAssar Westerlundlha/admin@@E.KTH.SE all 3535e9cd1aeSAssar Westerlundjimmy/admin@@E.KTH.SE all *@@E.KTH.SE 3545e9cd1aeSAssar Westerlundjimmy/admin@@E.KTH.SE all */*@@E.KTH.SE 3555e9cd1aeSAssar Westerlundmille/admin@@E.KTH.SE change-password *@@E.KTH.SE 3565e9cd1aeSAssar Westerlund@end example 3575e9cd1aeSAssar Westerlund 3585e9cd1aeSAssar Westerlund@node Password changing, Testing clients and servers, Remote administration, Setting up a realm 359b528cefcSMark Murray@section Password changing 360b528cefcSMark Murray 361c19800e8SDoug RabsonTo allow users to change their passwords, you should run @command{kpasswdd}. 362c19800e8SDoug RabsonIt is not run from @command{inetd}. 363b528cefcSMark Murray 364b528cefcSMark MurrayYou might need to add @samp{kpasswd} to your @file{/etc/services} as 365ae771770SStanislav Sedov@samp{464/udp}. If your realm is not setup to use DNS, you might also 366ae771770SStanislav Sedovneed to add a @samp{kpasswd_server} entry to the realm configuration 367ae771770SStanislav Sedovin @file{/etc/krb5.conf} on client machines: 368ae771770SStanislav Sedov 369ae771770SStanislav Sedov@example 370ae771770SStanislav Sedov[realms] 371ae771770SStanislav Sedov MY.REALM = @{ 372ae771770SStanislav Sedov kdc = my.kdc my.slave.kdc 373ae771770SStanislav Sedov kpasswd_server = my.kdc 374ae771770SStanislav Sedov @} 375ae771770SStanislav Sedov@end example 376b528cefcSMark Murray 377b528cefcSMark Murray@subsection Password quality assurance 378b528cefcSMark Murray 379b528cefcSMark MurrayIt is important that users have good passwords, both to make it harder 380c19800e8SDoug Rabsonto guess them and to avoid off-line attacks (although 381c19800e8SDoug Rabsonpre-authentication provides some defence against off-line attacks). 382c19800e8SDoug RabsonTo ensure that the users choose good passwords, you can enable 383c19800e8SDoug Rabsonpassword quality controls in @command{kpasswdd} and @command{kadmind}. 384c19800e8SDoug RabsonThe controls themselves are done in a shared library or an external 385c19800e8SDoug Rabsonprogram that is used by @command{kpasswdd}. To configure in these 386c19800e8SDoug Rabsoncontrols, add lines similar to the following to your 387c19800e8SDoug Rabson@file{/etc/krb5.conf}: 388b528cefcSMark Murray 389b528cefcSMark Murray@example 390b528cefcSMark Murray[password_quality] 391ae771770SStanislav Sedov policies = external-check builtin:minimum-length modulename:policyname 392c19800e8SDoug Rabson external_program = /bin/false 393c19800e8SDoug Rabson policy_libraries = @var{library1.so} @var{library2.so} 394b528cefcSMark Murray@end example 395b528cefcSMark Murray 396c19800e8SDoug RabsonIn @samp{[password_quality]policies} the module name is optional if 397c19800e8SDoug Rabsonthe policy name is unique in all modules (members of 398ae771770SStanislav Sedov@samp{policy_libraries}). All built-in policies can be qualified with 399ae771770SStanislav Sedova module name of @samp{builtin} to unambiguously specify the built-in 400ae771770SStanislav Sedovpolicy and not a policy by the same name from a loaded module. 401b528cefcSMark Murray 402ae771770SStanislav SedovThe built-in policies are 403c19800e8SDoug Rabson 404c19800e8SDoug Rabson@itemize @bullet 405c19800e8SDoug Rabson 406c19800e8SDoug Rabson@item external-check 407c19800e8SDoug Rabson 408c19800e8SDoug RabsonExecutes the program specified by @samp{[password_quality]external_program}. 409c19800e8SDoug Rabson 410c19800e8SDoug RabsonA number of key/value pairs are passed as input to the program, one per 411c19800e8SDoug Rabsonline, ending with the string @samp{end}. The key/value lines are of 412c19800e8SDoug Rabsonthe form 413b528cefcSMark Murray@example 414c19800e8SDoug Rabsonprincipal: @var{principal} 415c19800e8SDoug Rabsonnew-password: @var{password} 416b528cefcSMark Murray@end example 417c19800e8SDoug Rabsonwhere @var{password} is the password to check for the previous 418c19800e8SDoug Rabson@var{principal}. 419b528cefcSMark Murray 420c19800e8SDoug RabsonIf the external application approves the password, it should return 421c19800e8SDoug Rabson@samp{APPROVED} on standard out and exit with exit code 0. If it 422c19800e8SDoug Rabsondoesn't approve the password, an one line error message explaining the 423c19800e8SDoug Rabsonproblem should be returned on standard error and the application 424c19800e8SDoug Rabsonshould exit with exit code 0. In case of a fatal error, the 425c19800e8SDoug Rabsonapplication should, if possible, print an error message on standard 426c19800e8SDoug Rabsonerror and exit with a non-zero error code. 427c19800e8SDoug Rabson 428c19800e8SDoug Rabson@item minimum-length 429c19800e8SDoug Rabson 430c19800e8SDoug RabsonThe minimum length password quality check reads the configuration file 431c19800e8SDoug Rabsonstanza @samp{[password_quality]min_length} and requires the password 432c19800e8SDoug Rabsonto be at least this length. 433c19800e8SDoug Rabson 434c19800e8SDoug Rabson@item character-class 435c19800e8SDoug Rabson 436c19800e8SDoug RabsonThe character-class password quality check reads the configuration 437c19800e8SDoug Rabsonfile stanza @samp{[password_quality]min_classes}. The policy requires 438c19800e8SDoug Rabsonthe password to have characters from at least that many character 439c19800e8SDoug Rabsonclasses. Default value if not given is 3. 440c19800e8SDoug Rabson 441c19800e8SDoug RabsonThe four different characters classes are, uppercase, lowercase, 442c19800e8SDoug Rabsonnumber, special characters. 443c19800e8SDoug Rabson 444c19800e8SDoug Rabson@end itemize 445c19800e8SDoug Rabson 446c19800e8SDoug RabsonIf you want to write your own shared object to check password 447c19800e8SDoug Rabsonpolicies, see the manual page @manpage{kadm5_pwcheck,3}. 448b528cefcSMark Murray 449b528cefcSMark MurrayCode for a password quality checking function that uses the cracklib 450c19800e8SDoug Rabsonlibrary can be found in @file{lib/kadm5/sample_password_check.c} in 451c19800e8SDoug Rabsonthe source code distribution. It requires that the cracklib library 452c19800e8SDoug Rabsonbe built with the patch available at 453b528cefcSMark Murray@url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}. 454b528cefcSMark Murray 455c19800e8SDoug RabsonA sample policy external program is included in 456c19800e8SDoug Rabson@file{lib/kadm5/check-cracklib.pl}. 457c19800e8SDoug Rabson 458c19800e8SDoug RabsonIf no password quality checking function is configured, the only check 459c19800e8SDoug Rabsonperformed is that the password is at least six characters long. 460c19800e8SDoug Rabson 461c19800e8SDoug RabsonTo check the password policy settings, use the command 462ae771770SStanislav Sedov@command{verify-password-quality} in @command{kadmin} program. The password 463c19800e8SDoug Rabsonverification is only performed locally, on the client. It may be 464c19800e8SDoug Rabsonconvenient to set the environment variable @samp{KRB5_CONFIG} to point 465c19800e8SDoug Rabsonto a test version of @file{krb5.conf} while you're testing the 466c19800e8SDoug Rabson@samp{[password_quality]} stanza that way. 467b528cefcSMark Murray 4685e9cd1aeSAssar Westerlund@node Testing clients and servers, Slave Servers, Password changing, Setting up a realm 469b528cefcSMark Murray@section Testing clients and servers 470b528cefcSMark Murray 471b528cefcSMark MurrayNow you should be able to run all the clients and servers. Refer to the 472b528cefcSMark Murrayappropriate man pages for information on how to use them. 4735e9cd1aeSAssar Westerlund 4745e9cd1aeSAssar Westerlund@node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm 4755e9cd1aeSAssar Westerlund@section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm 4765e9cd1aeSAssar Westerlund 4775e9cd1aeSAssar WesterlundIt is desirable to have at least one backup (slave) server in case the 4785e9cd1aeSAssar Westerlundmaster server fails. It is possible to have any number of such slave 4795e9cd1aeSAssar Westerlundservers but more than three usually doesn't buy much more redundancy. 4805e9cd1aeSAssar Westerlund 481c19800e8SDoug RabsonAll Kerberos servers for a realm must have the same database so that 482c19800e8SDoug Rabsonthey present the same service to the users. The 4835e9cd1aeSAssar Westerlund@pindex hprop 484c19800e8SDoug Rabson@command{hprop} program, running on the master, will propagate the database 4855e9cd1aeSAssar Westerlundto the slaves, running 4865e9cd1aeSAssar Westerlund@pindex hpropd 487c19800e8SDoug Rabson@command{hpropd} processes. 4885e9cd1aeSAssar Westerlund 4891c43270aSJacques VidrineEvery slave needs a database directory, the master key (if it was used 4901c43270aSJacques Vidrinefor the database) and a keytab with the principal 4911c43270aSJacques Vidrine@samp{hprop/@var{hostname}}. Add the principal with the 4925e9cd1aeSAssar Westerlund@pindex ktutil 493c19800e8SDoug Rabson@command{ktutil} command and start 4945e9cd1aeSAssar Westerlund@pindex hpropd 495c19800e8SDoug Rabson@command{hpropd}, as follows: 4965e9cd1aeSAssar Westerlund 4975e9cd1aeSAssar Westerlund@example 498bbd80c28SJacques Vidrineslave# ktutil get -p foo/admin hprop/`hostname` 4991c43270aSJacques Vidrineslave# mkdir /var/heimdal 5005e9cd1aeSAssar Westerlundslave# hpropd 5015e9cd1aeSAssar Westerlund@end example 5025e9cd1aeSAssar Westerlund 5035e9cd1aeSAssar WesterlundThe master will use the principal @samp{kadmin/hprop} to authenticate to 5045e9cd1aeSAssar Westerlundthe slaves. This principal should be added when running @kbd{kadmin -l 5055e9cd1aeSAssar Westerlundinit} but if you do not have it in your database for whatever reason, 5065e9cd1aeSAssar Westerlundplease add it with @kbd{kadmin -l add}. 5075e9cd1aeSAssar Westerlund 5085e9cd1aeSAssar WesterlundThen run 5095e9cd1aeSAssar Westerlund@pindex hprop 5105e9cd1aeSAssar Westerlund@code{hprop} on the master: 5115e9cd1aeSAssar Westerlund 5125e9cd1aeSAssar Westerlund@example 5135e9cd1aeSAssar Westerlundmaster# hprop slave 5145e9cd1aeSAssar Westerlund@end example 5155e9cd1aeSAssar Westerlund 516c19800e8SDoug RabsonThis was just an hands-on example to make sure that everything was 517c19800e8SDoug Rabsonworking properly. Doing it manually is of course the wrong way, and to 5185e9cd1aeSAssar Westerlundautomate this you will want to start 5195e9cd1aeSAssar Westerlund@pindex hpropd 520c19800e8SDoug Rabson@command{hpropd} from @command{inetd} on the slave(s) and regularly run 5215e9cd1aeSAssar Westerlund@pindex hprop 522c19800e8SDoug Rabson@command{hprop} on the master to regularly propagate the database. 523c19800e8SDoug RabsonStarting the propagation once an hour from @command{cron} is probably a 5245e9cd1aeSAssar Westerlundgood idea. 5255e9cd1aeSAssar Westerlund 526c19800e8SDoug Rabson@node Incremental propagation, Encryption types and salting, Slave Servers, Setting up a realm 5275e9cd1aeSAssar Westerlund@section Incremental propagation 5285e9cd1aeSAssar Westerlund 529ae771770SStanislav SedovThere is also a newer mechanism for 5305e9cd1aeSAssar Westerlunddoing incremental propagation in Heimdal. Instead of sending the whole 5315e9cd1aeSAssar Westerlunddatabase regularly, it sends the changes as they happen on the master to 532c19800e8SDoug Rabsonthe slaves. The master keeps track of all the changes by assigning a 5335e9cd1aeSAssar Westerlundversion number to every change to the database. The slaves know which 5345e9cd1aeSAssar Westerlundwas the latest version they saw and in this way it can be determined if 535c19800e8SDoug Rabsonthey are in sync or not. A log of all the changes is kept on the master, 536c19800e8SDoug Rabsonand when a slave is at an older version than the oldest one in the 5375e9cd1aeSAssar Westerlundlog, the whole database has to be sent. 5385e9cd1aeSAssar Westerlund 539c19800e8SDoug RabsonProtocol-wise, all the slaves connect to the master and as a greeting 5405e9cd1aeSAssar Westerlundtell it the latest version that they have (@samp{IHAVE} message). The 5415e9cd1aeSAssar Westerlundmaster then responds by sending all the changes between that version and 5425e9cd1aeSAssar Westerlundthe current version at the master (a series of @samp{FORYOU} messages) 543c19800e8SDoug Rabsonor the whole database in a @samp{TELLYOUEVERYTHING} message. There is 544c19800e8SDoug Rabsonalso a keep-alive protocol that makes sure all slaves are up and running. 5455e9cd1aeSAssar Westerlund 546ae771770SStanislav SedovIn addition on listening on the network to get connection from new 547ae771770SStanislav Sedovslaves, the ipropd-master also listens on a status unix 548ae771770SStanislav Sedovsocket. kadmind and kpasswdd both open that socket when a transation 549ae771770SStanislav Sedovis done and written a notification to the socket. That cause 550ae771770SStanislav Sedovipropd-master to check for new version in the log file. As a fallback in 551ae771770SStanislav Sedovcase a notification is lost by the unix socket, the log file is 552ae771770SStanislav Sedovchecked after 30 seconds of no event. 553ae771770SStanislav Sedov 5545e9cd1aeSAssar Westerlund@subsection Configuring incremental propagation 5555e9cd1aeSAssar Westerlund 556c19800e8SDoug RabsonThe program that runs on the master is @command{ipropd-master} and all 557c19800e8SDoug Rabsonclients run @command{ipropd-slave}. 5585e9cd1aeSAssar Westerlund 5595e9cd1aeSAssar WesterlundCreate the file @file{/var/heimdal/slaves} on the master containing all 5605e9cd1aeSAssar Westerlundthe slaves that the database should be propagated to. Each line contains 5615e9cd1aeSAssar Westerlundthe full name of the principal (for example 5625e9cd1aeSAssar Westerlund@samp{iprop/hemligare.foo.se@@FOO.SE}). 5635e9cd1aeSAssar Westerlund 5645e9cd1aeSAssar WesterlundYou should already have @samp{iprop/tcp} defined as 2121, in your 5655e9cd1aeSAssar Westerlund@file{/etc/services}. Otherwise, or if you need to use a different port 5665e9cd1aeSAssar Westerlundfor some peculiar reason, you can use the @kbd{--port} option. This is 5675e9cd1aeSAssar Westerlunduseful when you have multiple realms to distribute from one server. 5685e9cd1aeSAssar Westerlund 569c19800e8SDoug RabsonThen you need to create those principals that you added in the 5705e9cd1aeSAssar Westerlundconfiguration file. Create one @samp{iprop/hostname} for the master and 5715e9cd1aeSAssar Westerlundfor every slave. 5725e9cd1aeSAssar Westerlund 5735e9cd1aeSAssar Westerlund 5745e9cd1aeSAssar Westerlund@example 5755e9cd1aeSAssar Westerlundmaster# /usr/heimdal/sbin/ktutil get iprop/`hostname` 5765e9cd1aeSAssar Westerlund@end example 5775e9cd1aeSAssar Westerlund 578ae771770SStanislav Sedov@example 579ae771770SStanislav Sedovslave# /usr/heimdal/sbin/ktutil get iprop/`hostname` 580ae771770SStanislav Sedov@end example 581ae771770SStanislav Sedov 582ae771770SStanislav Sedov 583c19800e8SDoug RabsonThe next step is to start the @command{ipropd-master} process on the master 584c19800e8SDoug Rabsonserver. The @command{ipropd-master} listens on the UNIX domain socket 5855e9cd1aeSAssar Westerlund@file{/var/heimdal/signal} to know when changes have been made to the 5865e9cd1aeSAssar Westerlunddatabase so they can be propagated to the slaves. There is also a 5875e9cd1aeSAssar Westerlundsafety feature of testing the version number regularly (every 30 5885e9cd1aeSAssar Westerlundseconds) to see if it has been modified by some means that do not raise 589c19800e8SDoug Rabsonthis signal. Then, start @command{ipropd-slave} on all the slaves: 5905e9cd1aeSAssar Westerlund 5915e9cd1aeSAssar Westerlund@example 5925e9cd1aeSAssar Westerlundmaster# /usr/heimdal/libexec/ipropd-master & 5935e9cd1aeSAssar Westerlundslave# /usr/heimdal/libexec/ipropd-slave master & 5945e9cd1aeSAssar Westerlund@end example 5955e9cd1aeSAssar Westerlund 596c19800e8SDoug RabsonTo manage the iprop log file you should use the @command{iprop-log} 597c19800e8SDoug Rabsoncommand. With it you can dump, truncate and replay the logfile. 5985e9cd1aeSAssar Westerlund 599ae771770SStanislav Sedov@node Encryption types and salting, Credential cache server - KCM, Incremental propagation, Setting up a realm 600c19800e8SDoug Rabson@section Encryption types and salting 601c19800e8SDoug Rabson@cindex Salting 602c19800e8SDoug Rabson@cindex Encryption types 603c19800e8SDoug Rabson 604c19800e8SDoug RabsonThe encryption types that the KDC is going to assign by default is 605c19800e8SDoug Rabsonpossible to change. Since the keys used for user authentication is 606c19800e8SDoug Rabsonsalted the encryption types are described together with the salt 607c19800e8SDoug Rabsonstrings. 608c19800e8SDoug Rabson 609c19800e8SDoug RabsonSalting is used to make it harder to pre-calculate all possible 6105e9cd1aeSAssar Westerlundkeys. Using a salt increases the search space to make it almost 611c19800e8SDoug Rabsonimpossible to pre-calculate all keys. Salting is the process of mixing a 6124137ff4cSJacques Vidrinepublic string (the salt) with the password, then sending it through an 613c19800e8SDoug Rabsonencryption type specific string-to-key function that will output the 6144137ff4cSJacques Vidrinefixed size encryption key. 6155e9cd1aeSAssar Westerlund 616c19800e8SDoug RabsonIn Kerberos 5 the salt is determined by the encryption type, except in 617c19800e8SDoug Rabsonsome special cases. 6184137ff4cSJacques Vidrine 6194137ff4cSJacques VidrineIn @code{des} there is the Kerberos 4 salt 6204137ff4cSJacques Vidrine(none at all) or the afs-salt (using the cell (realm in 621c19800e8SDoug RabsonAFS lingo)). 6224137ff4cSJacques Vidrine 6234137ff4cSJacques VidrineIn @code{arcfour} (the encryption type that Microsoft Windows 2000 uses) 6244137ff4cSJacques Vidrinethere is no salt. This is to be compatible with NTLM keys in Windows 6254137ff4cSJacques VidrineNT 4. 6264137ff4cSJacques Vidrine 6274137ff4cSJacques Vidrine@code{[kadmin]default_keys} in @file{krb5.conf} controls 628c19800e8SDoug Rabsonwhat salting to use. 6295e9cd1aeSAssar Westerlund 6305e9cd1aeSAssar WesterlundThe syntax of @code{[kadmin]default_keys} is 6315e9cd1aeSAssar Westerlund@samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption 632c19800e8SDoug Rabsontype (des-cbc-crc, arcfour-hmac-md5, aes256-cts-hmac-sha1-96), 633c19800e8SDoug Rabson@code{salt-type} is the type of salt (pw-salt or afs3-salt), and the 634c19800e8SDoug Rabsonsalt-string is the string that will be used as salt (remember that if 635c19800e8SDoug Rabsonthe salt is appended/prepended, the empty salt "" is the same thing as 636c19800e8SDoug Rabsonno salt at all). 6375e9cd1aeSAssar Westerlund 638c19800e8SDoug RabsonCommon types of salting include 6395e9cd1aeSAssar Westerlund 640adb0ddaeSAssar Westerlund@itemize @bullet 6415e9cd1aeSAssar Westerlund@item @code{v4} (or @code{des:pw-salt:}) 6425e9cd1aeSAssar Westerlund 643c19800e8SDoug RabsonThe Kerberos 4 salting is using no salt at all. Reason there is colon 644c19800e8SDoug Rabsonat the end of the salt string is that it makes the salt the empty 645bbd80c28SJacques Vidrinestring (same as no salt). 6465e9cd1aeSAssar Westerlund 6475e9cd1aeSAssar Westerlund@item @code{v5} (or @code{pw-salt}) 6485e9cd1aeSAssar Westerlund 649c19800e8SDoug Rabson@code{pw-salt} uses the default salt for each encryption type is 650c19800e8SDoug Rabsonspecified for. If the encryption type @samp{etype} isn't given, all 651c19800e8SDoug Rabsondefault encryption will be used. 6525e9cd1aeSAssar Westerlund 6535e9cd1aeSAssar Westerlund@item @code{afs3-salt} 6545e9cd1aeSAssar Westerlund 655c19800e8SDoug Rabson@code{afs3-salt} is the salt that is used with Transarc kaserver. It's 656c19800e8SDoug Rabsonthe cell name appended to the password. 6575e9cd1aeSAssar Westerlund 6585e9cd1aeSAssar Westerlund@end itemize 6591c43270aSJacques Vidrine 660ae771770SStanislav Sedov@node Credential cache server - KCM, Cross realm, Encryption types and salting, Setting up a realm 661ae771770SStanislav Sedov@section Credential cache server - KCM 662ae771770SStanislav Sedov@cindex KCM 663ae771770SStanislav Sedov@cindex Credential cache server 664ae771770SStanislav Sedov 665ae771770SStanislav SedovWhen KCM running is easy for users to switch between different 666ae771770SStanislav Sedovkerberos principals using @file{kswitch} or built in support in 667ae771770SStanislav Sedovapplication, like OpenSSH's GSSAPIClientIdentity. 668ae771770SStanislav Sedov 669ae771770SStanislav SedovOther advantages are that there is the long term credentials are not 670ae771770SStanislav Sedovwritten to disk and on reboot the credential is removed when kcm 671ae771770SStanislav Sedovprocess stopps running. 672ae771770SStanislav Sedov 673ae771770SStanislav SedovConfigure the system startup script to start the kcm process, 674ae771770SStanislav Sedov@file{/usr/heimdal/libexec/kcm} and then configure the system to use kcm in @file{krb5.conf}. 675ae771770SStanislav Sedov 676ae771770SStanislav Sedov@example 677ae771770SStanislav Sedov[libdefaults] 678ae771770SStanislav Sedov default_cc_type = KCM 679ae771770SStanislav Sedov@end example 680ae771770SStanislav Sedov 681ae771770SStanislav SedovNow when you run @command{kinit} it doesn't overwrite your existing 682ae771770SStanislav Sedovcredentials but rather just add them to the set of 683ae771770SStanislav Sedovcredentials. @command{klist -l} lists the credentials and the star 684ae771770SStanislav Sedovmarks the default credential. 685ae771770SStanislav Sedov 686ae771770SStanislav Sedov@example 687ae771770SStanislav Sedov$ kinit lha@@KTH.SE 688ae771770SStanislav Sedovlha@@KTH.SE's Password: 689ae771770SStanislav Sedov$ klist -l 690ae771770SStanislav Sedov Name Cache name Expires 691ae771770SStanislav Sedovlha@@KTH.SE 0 Nov 22 23:09:40 * 692ae771770SStanislav Sedovlha@@SU.SE Initial default ccache Nov 22 14:14:24 693ae771770SStanislav Sedov@end example 694ae771770SStanislav Sedov 695ae771770SStanislav SedovWhen switching between credentials you can use @command{kswitch}. 696ae771770SStanislav Sedov 697ae771770SStanislav Sedov@example 698ae771770SStanislav Sedov$ kswitch -i 699ae771770SStanislav Sedov Principal 700ae771770SStanislav Sedov1 lha@@KTH.SE 701ae771770SStanislav Sedov2 lha@@SU.SE 702ae771770SStanislav SedovSelect number: 2 703ae771770SStanislav Sedov@end example 704ae771770SStanislav Sedov 705ae771770SStanislav SedovAfter switching, a new set of credentials are used as default. 706ae771770SStanislav Sedov 707ae771770SStanislav Sedov@example 708ae771770SStanislav Sedov$ klist -l 709ae771770SStanislav Sedov Name Cache name Expires 710ae771770SStanislav Sedovlha@@SU.SE Initial default ccache Nov 22 14:14:24 * 711ae771770SStanislav Sedovlha@@KTH.SE 0 Nov 22 23:09:40 712ae771770SStanislav Sedov@end example 713ae771770SStanislav Sedov 714ae771770SStanislav SedovSom applications, like openssh with Simon Wilkinsons patch applied, 715ae771770SStanislav Sedovsupport specifiying that credential to use. The example below will 716ae771770SStanislav Sedovlogin to the host computer.kth.se using lha@@KTH.SE (not the current 717ae771770SStanislav Sedovdefault credential). 718ae771770SStanislav Sedov 719ae771770SStanislav Sedov@example 720ae771770SStanislav Sedov$ ssh \ 721ae771770SStanislav Sedov -o GSSAPIAuthentication=yes \ 722ae771770SStanislav Sedov -o GSSAPIKeyExchange=yes \ 723ae771770SStanislav Sedov -o GSSAPIClientIdentity=lha@@KTH.SE \ 724ae771770SStanislav Sedov computer.kth.se 725ae771770SStanislav Sedov@end example 726ae771770SStanislav Sedov 727ae771770SStanislav Sedov 728ae771770SStanislav Sedov 729ae771770SStanislav Sedov@node Cross realm, Transit policy, Credential cache server - KCM, Setting up a realm 7301c43270aSJacques Vidrine@section Cross realm 7311c43270aSJacques Vidrine@cindex Cross realm 7321c43270aSJacques Vidrine 733c19800e8SDoug RabsonSuppose you reside in the realm @samp{MY.REALM}, how do you 7341c43270aSJacques Vidrineauthenticate to a server in @samp{OTHER.REALM}? Having valid tickets in 735c19800e8SDoug Rabson@samp{MY.REALM} allows you to communicate with Kerberised services in that 7361c43270aSJacques Vidrinerealm. However, the computer in the other realm does not have a secret 7371c43270aSJacques Vidrinekey shared with the Kerberos server in your realm. 7381c43270aSJacques Vidrine 739c19800e8SDoug RabsonIt is possible to share keys between two realms that trust each 740c19800e8SDoug Rabsonother. When a client program, such as @command{telnet} or @command{ssh}, 7411c43270aSJacques Vidrinefinds that the other computer is in a different realm, it will try to 7421c43270aSJacques Vidrineget a ticket granting ticket for that other realm, but from the local 7431c43270aSJacques VidrineKerberos server. With that ticket granting ticket, it will then obtain 7441c43270aSJacques Vidrineservice tickets from the Kerberos server in the other realm. 7451c43270aSJacques Vidrine 7461c43270aSJacques VidrineFor a two way trust between @samp{MY.REALM} and @samp{OTHER.REALM} 7471c43270aSJacques Vidrineadd the following principals to each realm. The principals should be 7481c43270aSJacques Vidrine@samp{krbtgt/OTHER.REALM@@MY.REALM} and 7491c43270aSJacques Vidrine@samp{krbtgt/MY.REALM@@OTHER.REALM} in @samp{MY.REALM}, and 7501c43270aSJacques Vidrine@samp{krbtgt/MY.REALM@@OTHER.REALM} and 7511c43270aSJacques Vidrine@samp{krbtgt/OTHER.REALM@@MY.REALM}in @samp{OTHER.REALM}. 7521c43270aSJacques Vidrine 753c19800e8SDoug RabsonIn Kerberos 5 the trust can be configured to be one way. So that 7541c43270aSJacques Vidrineusers from @samp{MY.REALM} can authenticate to services in 7551c43270aSJacques Vidrine@samp{OTHER.REALM}, but not the opposite. In the example above, the 7561c43270aSJacques Vidrine@samp{krbtgt/MY.REALM@@OTHER.REALM} then should be removed. 7571c43270aSJacques Vidrine 7581c43270aSJacques VidrineThe two principals must have the same key, key version number, and the 7591c43270aSJacques Vidrinesame set of encryption types. Remember to transfer the two keys in a 7601c43270aSJacques Vidrinesafe manner. 7611c43270aSJacques Vidrine 7621c43270aSJacques Vidrine@example 7631c43270aSJacques Vidrinevr$ klist 7641c43270aSJacques VidrineCredentials cache: FILE:/tmp/krb5cc_913.console 7651c43270aSJacques Vidrine Principal: lha@@E.KTH.SE 7661c43270aSJacques Vidrine 7671c43270aSJacques Vidrine Issued Expires Principal 7681c43270aSJacques VidrineMay 3 13:55:52 May 3 23:55:54 krbtgt/E.KTH.SE@@E.KTH.SE 7691c43270aSJacques Vidrine 7701c43270aSJacques Vidrinevr$ telnet -l lha hummel.it.su.se 7711c43270aSJacques VidrineTrying 2001:6b0:5:1095:250:fcff:fe24:dbf... 7721c43270aSJacques VidrineConnected to hummel.it.su.se. 7731c43270aSJacques VidrineEscape character is '^]'. 7741c43270aSJacques VidrineWaiting for encryption to be negotiated... 7751c43270aSJacques Vidrine[ Trying mutual KERBEROS5 (host/hummel.it.su.se@@SU.SE)... ] 7761c43270aSJacques Vidrine[ Kerberos V5 accepts you as ``lha@@E.KTH.SE'' ] 7771c43270aSJacques VidrineEncryption negotiated. 7781c43270aSJacques VidrineLast login: Sat May 3 14:11:47 from vr.l.nxs.se 7791c43270aSJacques Vidrinehummel$ exit 7801c43270aSJacques Vidrine 7811c43270aSJacques Vidrinevr$ klist 7821c43270aSJacques VidrineCredentials cache: FILE:/tmp/krb5cc_913.console 7831c43270aSJacques Vidrine Principal: lha@@E.KTH.SE 7841c43270aSJacques Vidrine 7851c43270aSJacques Vidrine Issued Expires Principal 7861c43270aSJacques VidrineMay 3 13:55:52 May 3 23:55:54 krbtgt/E.KTH.SE@@E.KTH.SE 7871c43270aSJacques VidrineMay 3 13:55:56 May 3 23:55:54 krbtgt/SU.SE@@E.KTH.SE 7881c43270aSJacques VidrineMay 3 14:10:54 May 3 23:55:54 host/hummel.it.su.se@@SU.SE 7891c43270aSJacques Vidrine 7901c43270aSJacques Vidrine@end example 7911c43270aSJacques Vidrine 7921c43270aSJacques Vidrine@node Transit policy, Setting up DNS, Cross realm, Setting up a realm 7931c43270aSJacques Vidrine@section Transit policy 7941c43270aSJacques Vidrine@cindex Transit policy 7951c43270aSJacques Vidrine 796ae771770SStanislav SedovUnder some circumstances, you may not wish to set up direct 797ae771770SStanislav Sedovcross-realm trust with every realm to which you wish to authenticate 798ae771770SStanislav Sedovor from which you wish to accept authentications. Kerberos supports 799ae771770SStanislav Sedovmulti-hop cross-realm trust where a client principal in realm A 800ae771770SStanislav Sedovauthenticates to a service in realm C through a realm B with which 801ae771770SStanislav Sedovboth A and C have cross-realm trust relationships. In this situation, 802ae771770SStanislav SedovA and C need not set up cross-realm principals between each other. 803ae771770SStanislav Sedov 804ae771770SStanislav SedovIf you want to use cross-realm authentication through an intermediate 805ae771770SStanislav Sedovrealm, it must be explicitly allowed by either the KDCs for the realm 806ae771770SStanislav Sedovto which the client is authenticating (in this case, realm C), or the 807ae771770SStanislav Sedovserver receiving the request. This is done in @file{krb5.conf} in the 8081c43270aSJacques Vidrine@code{[capaths]} section. 8091c43270aSJacques Vidrine 810ae771770SStanislav SedovIn addition, the client in realm A need to be configured to know how 811ae771770SStanislav Sedovto reach realm C via realm B. This can be done either on the client or 812ae771770SStanislav Sedovvia KDC configuration in the KDC for realm A. 813ae771770SStanislav Sedov 814ae771770SStanislav Sedov@subsection Allowing cross-realm transits 815ae771770SStanislav Sedov 8161c43270aSJacques VidrineWhen the ticket transits through a realm to another realm, the 8171c43270aSJacques Vidrinedestination realm adds its peer to the "transited-realms" field in the 818ae771770SStanislav Sedovticket. The field is unordered, since there is no way to know if know 819ae771770SStanislav Sedovif one of the transited-realms changed the order of the list. For the 820ae771770SStanislav Sedovauthentication to be accepted by the final destination realm, all of 821ae771770SStanislav Sedovthe transited realms must be listed as trusted in the @code{[capaths]} 822ae771770SStanislav Sedovconfiguration, either in the KDC for the destination realm or on the 823ae771770SStanislav Sedovserver receiving the authentication. 8241c43270aSJacques Vidrine 825ae771770SStanislav SedovThe syntax for @code{[capaths]} section is: 8261c43270aSJacques Vidrine 8271c43270aSJacques Vidrine@example 8281c43270aSJacques Vidrine[capaths] 8291c43270aSJacques Vidrine CLIENT-REALM = @{ 8301c43270aSJacques Vidrine SERVER-REALM = PERMITTED-CROSS-REALMS ... 8311c43270aSJacques Vidrine @} 8321c43270aSJacques Vidrine@end example 8331c43270aSJacques Vidrine 834ae771770SStanislav SedovIn the following example, the realm @code{STACKEN.KTH.SE} only has 835ae771770SStanislav Sedovdirect cross-realm set up with @code{KTH.SE}. @code{KTH.SE} has 836ae771770SStanislav Sedovdirect cross-realm set up with @code{STACKEN.KTH.SE} and @code{SU.SE}. 837ae771770SStanislav Sedov@code{DSV.SU.SE} only has direct cross-realm set up with @code{SU.SE}. 838ae771770SStanislav SedovThe goal is to allow principals in the @code{DSV.SU.SE} or 839ae771770SStanislav Sedov@code{SU.SE} realms to authenticate to services in 840ae771770SStanislav Sedov@code{STACKEN.KTH.SE}. This is done with the following 841ae771770SStanislav Sedov@code{[capaths]} entry on either the server accepting authentication 842ae771770SStanislav Sedovor on the KDC for @code{STACKEN.KTH.SE}. 8431c43270aSJacques Vidrine 8441c43270aSJacques Vidrine@example 8451c43270aSJacques Vidrine[capaths] 8461c43270aSJacques Vidrine SU.SE = @{ 8471c43270aSJacques Vidrine STACKEN.KTH.SE = KTH.SE 8481c43270aSJacques Vidrine @} 8491c43270aSJacques Vidrine DSV.SU.SE = @{ 8501c43270aSJacques Vidrine STACKEN.KTH.SE = SU.SE KTH.SE 8511c43270aSJacques Vidrine @} 8521c43270aSJacques Vidrine@end example 8531c43270aSJacques Vidrine 854ae771770SStanislav SedovThe first entry allows cross-realm authentication from clients in 855ae771770SStanislav Sedov@code{SU.SE} transiting through @code{KTH.SE} to 856ae771770SStanislav Sedov@code{STACKEN.KTH.SE}. The second entry allows cross-realm 857ae771770SStanislav Sedovauthentication from clients in @code{DSV.SU.SE} transiting through 858ae771770SStanislav Sedovboth @code{SU.SE} and @code{KTH.SE} to @code{STACKEN.KTH.SE}. 859ae771770SStanislav Sedov 860ae771770SStanislav SedovBe careful of which realm goes where; it's easy to put realms in the 861ae771770SStanislav Sedovwrong place. The block is tagged with the client realm (the realm of 862ae771770SStanislav Sedovthe principal authenticating), and the realm before the equal sign is 863ae771770SStanislav Sedovthe final destination realm: the realm to which the client is 864ae771770SStanislav Sedovauthenticating. After the equal sign go all the realms that the 865ae771770SStanislav Sedovclient transits through. 866ae771770SStanislav Sedov 867c19800e8SDoug RabsonThe order of the @code{PERMITTED-CROSS-REALMS} is not important when 868c19800e8SDoug Rabsondoing transit cross realm verification. 869c19800e8SDoug Rabson 870ae771770SStanislav Sedov@subsection Configuring client cross-realm transits 871ae771770SStanislav Sedov 872ae771770SStanislav SedovThe @code{[capaths]} section is also used for another purpose: to tell 873ae771770SStanislav Sedovclients which realm to transit through to reach a realm with which 874ae771770SStanislav Sedovtheir local realm does not have cross-realm trust. This can be done 875ae771770SStanislav Sedovby either putting a @code{[capaths]} entry in the configuration of the 876ae771770SStanislav Sedovclient or by putting the entry in the configuration of the KDC for the 877ae771770SStanislav Sedovclient's local realm. In the latter case, the KDC will then hand back 878ae771770SStanislav Sedova referral to the client when the client requests a cross-realm ticket 879ae771770SStanislav Sedovto the destination realm, telling the client to try to go through an 880ae771770SStanislav Sedovintermediate realm. 881ae771770SStanislav Sedov 882ae771770SStanislav SedovFor client configuration, the order of @code{PERMITTED-CROSS-REALMS} 883ae771770SStanislav Sedovis significant, since only the first realm in this section (after the 884ae771770SStanislav Sedovequal sign) is used by the client. 885ae771770SStanislav Sedov 886ae771770SStanislav SedovFor example, again consider the @code{[capaths]} entry above for the 887ae771770SStanislav Sedovcase of a client in the @code{SU.SE} realm, and assume that the client 888ae771770SStanislav Sedovor the @code{SU.SE} KDC has that @code{[capaths]} entry. If the 889ae771770SStanislav Sedovclient attempts to authenticate to a service in the 890ae771770SStanislav Sedov@code{STACKEN.KTH.SE} realm, that entry says to first authenticate 891ae771770SStanislav Sedovcross-realm to the @code{KTH.SE} realm (the first realm listed in the 892ae771770SStanislav Sedov@code{PERMITTED-CROSS-REALMS} section), and then from there to 893ae771770SStanislav Sedov@code{STACKEN.KTH.SE}. 894ae771770SStanislav Sedov 895ae771770SStanislav SedovEach entry in @code{[capaths]} can only give the next hop, since only 896ae771770SStanislav Sedovthe first realm in @code{PERMITTED-CROSS-REALMS} is used. If, for 897ae771770SStanislav Sedovinstance, a client in @code{DSV.SU.SE} had a @code{[capaths]} 898ae771770SStanislav Sedovconfiguration as above but without the first block for @code{SU.SE}, 899ae771770SStanislav Sedovthey would not be able to reach @code{STACKEN.KTH.SE}. They would get 900ae771770SStanislav Sedovas far as @code{SU.SE} based on the @code{DSV.SU.SE} entry in 901ae771770SStanislav Sedov@code{[capaths]} and then attempt to go directly from there to 902ae771770SStanislav Sedov@code{STACKEN.KTH.SE} and get stuck (unless, of course, the 903ae771770SStanislav Sedov@code{SU.SE} KDC had the additional entry required to tell the client 904ae771770SStanislav Sedovto go through @code{KTH.SE}). 905ae771770SStanislav Sedov 906ae771770SStanislav Sedov@subsection Active Directory forest example 907ae771770SStanislav Sedov 908ae771770SStanislav SedovOne common place where a @code{[capaths]} configuration is desirable 909ae771770SStanislav Sedovis with Windows Active Directory forests. One common Active Directory 910ae771770SStanislav Sedovconfiguration is to have one top-level Active Directory realm but then 911ae771770SStanislav Sedovdivide systems, services, and users into child realms (perhaps based 912ae771770SStanislav Sedovon organizational unit). One generally establishes cross-realm trust 913ae771770SStanislav Sedovonly with the top-level realm, and then uses transit policy to permit 914ae771770SStanislav Sedovauthentications to and from the child realms. 915ae771770SStanislav Sedov 916ae771770SStanislav SedovFor example, suppose an organization has a Heimdal realm 917ae771770SStanislav Sedov@code{EXAMPLE.COM}, a Windows Active Directory realm 918ae771770SStanislav Sedov@code{WIN.EXAMPLE.COM}, and then child Active Directory realms 919ae771770SStanislav Sedov@code{ENGR.WIN.EXAMPLE.COM} and @code{SALES.WIN.EXAMPLE.COM}. The 920ae771770SStanislav Sedovgoal is to allow users in any of these realms to authenticate to 921ae771770SStanislav Sedovservices in any of these realms. The @code{EXAMPLE.COM} KDC (and 922ae771770SStanislav Sedovpossibly client) configuration should therefore contain a 923ae771770SStanislav Sedov@code{[capaths]} section as follows: 924ae771770SStanislav Sedov 925ae771770SStanislav Sedov@example 926ae771770SStanislav Sedov[capaths] 927ae771770SStanislav Sedov ENGR.WIN.EXAMPLE.COM = @{ 928ae771770SStanislav Sedov EXAMPLE.COM = WIN.EXAMPLE.COM 929ae771770SStanislav Sedov @} 930ae771770SStanislav Sedov SALES.WIN.EXAMPLE.COM = @{ 931ae771770SStanislav Sedov EXAMPLE.COM = WIN.EXAMPLE.COM 932ae771770SStanislav Sedov @} 933ae771770SStanislav Sedov EXAMPLE.COM = @{ 934ae771770SStanislav Sedov ENGR.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM 935ae771770SStanislav Sedov SALES.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM 936ae771770SStanislav Sedov @} 937ae771770SStanislav Sedov@end example 938ae771770SStanislav Sedov 939ae771770SStanislav SedovThe first two blocks allow clients in the @code{ENGR.WIN.EXAMPLE.COM} 940ae771770SStanislav Sedovand @code{SALES.WIN.EXAMPLE.COM} realms to authenticate to services in 941ae771770SStanislav Sedovthe @code{EXAMPLE.COM} realm. The third block tells the client (or 942ae771770SStanislav Sedovtells the KDC to tell the client via referrals) to transit through 943ae771770SStanislav Sedov@code{WIN.EXAMPLE.COM} to reach these realms. Both sides of the 944ae771770SStanislav Sedovconfiguration are needed for bi-directional transited cross-realm 945ae771770SStanislav Sedovauthentication. 946c19800e8SDoug Rabson 9471c43270aSJacques Vidrine@c To test the cross realm configuration, use: 9481c43270aSJacques Vidrine@c kmumble transit-check client server transit-realms ... 9491c43270aSJacques Vidrine 950c19800e8SDoug Rabson@node Setting up DNS, Using LDAP to store the database, Transit policy, Setting up a realm 9511c43270aSJacques Vidrine@section Setting up DNS 9521c43270aSJacques Vidrine@cindex Setting up DNS 9531c43270aSJacques Vidrine 954c19800e8SDoug Rabson@subsection Using DNS to find KDC 955c19800e8SDoug Rabson 9561c43270aSJacques VidrineIf there is information about where to find the KDC or kadmind for a 9571c43270aSJacques Vidrinerealm in the @file{krb5.conf} for a realm, that information will be 958c19800e8SDoug Rabsonpreferred, and DNS will not be queried. 9591c43270aSJacques Vidrine 9601c43270aSJacques VidrineHeimdal will try to use DNS to find the KDCs for a realm. First it 961c19800e8SDoug Rabsonwill try to find a @code{SRV} resource record (RR) for the realm. If no 962c19800e8SDoug RabsonSRV RRs are found, it will fall back to looking for an @code{A} RR for 9631c43270aSJacques Vidrinea machine named kerberos.REALM, and then kerberos-1.REALM, etc 9641c43270aSJacques Vidrine 965c19800e8SDoug RabsonAdding this information to DNS minimises the client configuration (in 966c19800e8SDoug Rabsonthe common case, resulting in no configuration needed) and allows the 9671c43270aSJacques Vidrinesystem administrator to change the number of KDCs and on what machines 9681c43270aSJacques Vidrinethey are running without caring about clients. 9691c43270aSJacques Vidrine 970c19800e8SDoug RabsonThe downside of using DNS is that the client might be fooled to use the 9711c43270aSJacques Vidrinewrong server if someone fakes DNS replies/data, but storing the IP 9721c43270aSJacques Vidrineaddresses of the KDC on all the clients makes it very hard to change 9731c43270aSJacques Vidrinethe infrastructure. 9741c43270aSJacques Vidrine 975c19800e8SDoug RabsonAn example of the configuration for the realm @code{EXAMPLE.COM}: 9761c43270aSJacques Vidrine 9771c43270aSJacques Vidrine@example 9781c43270aSJacques Vidrine 9791c43270aSJacques Vidrine$ORIGIN example.com. 9801c43270aSJacques Vidrine_kerberos._tcp SRV 10 1 88 kerberos.example.com. 9811c43270aSJacques Vidrine_kerberos._udp SRV 10 1 88 kerberos.example.com. 9821c43270aSJacques Vidrine_kerberos._tcp SRV 10 1 88 kerberos-1.example.com. 9831c43270aSJacques Vidrine_kerberos._udp SRV 10 1 88 kerberos-1.example.com. 9841c43270aSJacques Vidrine_kpasswd._udp SRV 10 1 464 kerberos.example.com. 9851c43270aSJacques Vidrine_kerberos-adm._tcp SRV 10 1 749 kerberos.example.com. 9861c43270aSJacques Vidrine 9871c43270aSJacques Vidrine@end example 9881c43270aSJacques Vidrine 9891c43270aSJacques VidrineMore information about DNS SRV resource records can be found in 9901c43270aSJacques VidrineRFC-2782 (A DNS RR for specifying the location of services (DNS SRV)). 9911c43270aSJacques Vidrine 992c19800e8SDoug Rabson@subsection Using DNS to map hostname to Kerberos realm 993c19800e8SDoug Rabson 994c19800e8SDoug RabsonHeimdal also supports a way to lookup a realm from a hostname. This to 995c19800e8SDoug Rabsonminimise configuration needed on clients. Using this has the drawback 996c19800e8SDoug Rabsonthat clients can be redirected by an attacker to realms within the 997c19800e8SDoug Rabsonsame cross realm trust and made to believe they are talking to the 998c19800e8SDoug Rabsonright server (since Kerberos authentication will succeed). 999c19800e8SDoug Rabson 1000c19800e8SDoug RabsonAn example configuration that informs clients that for the realms 1001c19800e8SDoug Rabsonit.example.com and srv.example.com, they should use the realm 1002c19800e8SDoug RabsonEXAMPLE.COM: 1003c19800e8SDoug Rabson 1004c19800e8SDoug Rabson@example 1005c19800e8SDoug Rabson 1006c19800e8SDoug Rabson$ORIGIN example.com. 1007c19800e8SDoug Rabson_kerberos.it TXT "EXAMPLE.COM" 1008c19800e8SDoug Rabson_kerberos.srv TXT "EXAMPLE.COM" 1009c19800e8SDoug Rabson 1010c19800e8SDoug Rabson@end example 1011c19800e8SDoug Rabson 1012c19800e8SDoug Rabson@node Using LDAP to store the database, Providing Kerberos credentials to servers and programs, Setting up DNS, Setting up a realm 1013c19800e8SDoug Rabson@section Using LDAP to store the database 1014c19800e8SDoug Rabson@cindex Using the LDAP backend 1015c19800e8SDoug Rabson 1016c19800e8SDoug RabsonThis document describes how to install the LDAP backend for 1017c19800e8SDoug RabsonHeimdal. Note that before attempting to configure such an 1018c19800e8SDoug Rabsoninstallation, you should be aware of the implications of storing 1019c19800e8SDoug Rabsonprivate information (such as users' keys) in a directory service 1020c19800e8SDoug Rabsonprimarily designed for public information. Nonetheless, with a 1021c19800e8SDoug Rabsonsuitable authorisation policy, it is possible to set this up in a 1022c19800e8SDoug Rabsonsecure fashion. A knowledge of LDAP, Kerberos, and C is necessary to 1023c19800e8SDoug Rabsoninstall this backend. The HDB schema was devised by Leif Johansson. 1024c19800e8SDoug Rabson 1025ae771770SStanislav SedovThis assumes, OpenLDAP 2.3 or later. 1026ae771770SStanislav Sedov 1027c19800e8SDoug RabsonRequirements: 1028c19800e8SDoug Rabson 1029c19800e8SDoug Rabson@itemize @bullet 1030c19800e8SDoug Rabson 1031c19800e8SDoug Rabson@item 1032c19800e8SDoug RabsonA current release of Heimdal, configured with 1033c19800e8SDoug Rabson@code{--with-openldap=/usr/local} (adjust according to where you have 1034c19800e8SDoug Rabsoninstalled OpenLDAP). 1035c19800e8SDoug Rabson 1036c19800e8SDoug RabsonYou can verify that you manage to configure LDAP support by running 1037c19800e8SDoug Rabson@file{kdc --builtin-hdb}, and checking that @samp{ldap:} is one entry 1038c19800e8SDoug Rabsonin the list. 1039c19800e8SDoug Rabson 1040c19800e8SDoug RabsonIts also possible to configure the ldap backend as a shared module, 1041c19800e8SDoug Rabsonsee option --hdb-openldap-module to configure. 1042c19800e8SDoug Rabson 1043c19800e8SDoug Rabson@item 1044ae771770SStanislav SedovConfigure OpenLDAP with @kbd{--enable-local} to enable the local transport. 1045c19800e8SDoug Rabson 1046c19800e8SDoug Rabson@item 1047c19800e8SDoug RabsonAdd the hdb schema to the LDAP server, it's included in the source-tree 1048c19800e8SDoug Rabsonin @file{lib/hdb/hdb.schema}. Example from slapd.conf: 1049c19800e8SDoug Rabson 1050c19800e8SDoug Rabson@example 1051c19800e8SDoug Rabsoninclude /usr/local/etc/openldap/schema/hdb.schema 1052c19800e8SDoug Rabson@end example 1053c19800e8SDoug Rabson 1054c19800e8SDoug Rabson@item 1055c19800e8SDoug RabsonConfigure the LDAP server ACLs to accept writes from clients over the 1056c19800e8SDoug Rabsonlocal transport. For example: 1057c19800e8SDoug Rabson 1058c19800e8SDoug Rabson@example 1059c19800e8SDoug Rabsonaccess to * 1060c19800e8SDoug Rabson by dn.exact="uid=heimdal,dc=services,dc=example,dc=com" write 1061c19800e8SDoug Rabson ... 1062c19800e8SDoug Rabson 1063ae771770SStanislav Sedovauthz-regexp "gidNumber=.*\\\+uidNumber=0,cn=peercred,cn=external,cn=auth'' 1064c19800e8SDoug Rabson "uid=heimdal,dc=services,dc=example,dc=com" 1065c19800e8SDoug Rabson 1066c19800e8SDoug Rabson@end example 1067c19800e8SDoug Rabson 1068c19800e8SDoug RabsonThe sasl-regexp is for mapping between the SASL/EXTERNAL and a user in 1069c19800e8SDoug Rabsona tree. The user that the key is mapped to should be have a 1070c19800e8SDoug Rabsonkrb5Principal aux object with krb5PrincipalName set so that the 1071c19800e8SDoug Rabson``creator'' and ``modifier'' is right in @file{kadmin}. 1072c19800e8SDoug Rabson 1073c19800e8SDoug RabsonAnother option is to create an admins group and add the dn to that 1074c19800e8SDoug Rabsongroup. 1075c19800e8SDoug Rabson 1076c19800e8SDoug RabsonSince Heimdal talks to the LDAP server over a UNIX domain socket, and 1077c19800e8SDoug Rabsonuses external sasl authentication, it's not possible to require 1078c19800e8SDoug Rabsonsecurity layer quality (ssf in cyrus-sasl lingo). So that requirement 1079c19800e8SDoug Rabsonhas to be turned off in OpenLDAP @command{slapd} configuration file 1080c19800e8SDoug Rabson@file{slapd.conf}. 1081c19800e8SDoug Rabson 1082c19800e8SDoug Rabson@example 1083c19800e8SDoug Rabsonsasl-secprops minssf=0 1084c19800e8SDoug Rabson@end example 1085c19800e8SDoug Rabson 1086c19800e8SDoug Rabson@item 1087c19800e8SDoug Rabson 1088c19800e8SDoug RabsonStart @command{slapd} with the local listener (as well as the default TCP/IP 1089c19800e8SDoug Rabsonlistener on port 389) as follows: 1090c19800e8SDoug Rabson 1091c19800e8SDoug Rabson@example 1092c19800e8SDoug Rabson slapd -h "ldapi:/// ldap:///" 1093c19800e8SDoug Rabson@end example 1094c19800e8SDoug Rabson 1095c19800e8SDoug RabsonNote: These is a bug in @command{slapd} where it appears to corrupt the krb5Key 1096c19800e8SDoug Rabsonbinary attribute on shutdown. This may be related to our use of the V3 1097c19800e8SDoug Rabsonschema definition syntax instead of the old UMich-style, V2 syntax. 1098c19800e8SDoug Rabson 1099c19800e8SDoug Rabson@item 1100c19800e8SDoug RabsonYou should specify the distinguished name under which your 1101c19800e8SDoug Rabsonprincipals will be stored in @file{krb5.conf}. Also you need to 1102c19800e8SDoug Rabsonenter the path to the kadmin acl file: 1103c19800e8SDoug Rabson 1104c19800e8SDoug Rabson 1105c19800e8SDoug Rabson@example 1106c19800e8SDoug Rabson[kdc] 1107c19800e8SDoug Rabson database = @{ 1108c19800e8SDoug Rabson dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com 1109c19800e8SDoug Rabson hdb-ldap-structural-object = inetOrgPerson 1110c19800e8SDoug Rabson acl_file = /path/to/kadmind.acl 1111c19800e8SDoug Rabson mkey_file = /path/to/mkey 1112c19800e8SDoug Rabson @} 1113c19800e8SDoug Rabson@end example 1114c19800e8SDoug Rabson 1115c19800e8SDoug Rabson@samp{mkey_file} can be excluded if you feel that you trust your ldap 1116c19800e8SDoug Rabsondirectory to have the raw keys inside it. The 1117c19800e8SDoug Rabsonhdb-ldap-structural-object is not necessary if you do not need Samba 1118c19800e8SDoug Rabsoncomatibility. 1119c19800e8SDoug Rabson 1120c19800e8SDoug Rabson 1121c19800e8SDoug Rabson 1122c19800e8SDoug Rabson@item 1123c19800e8SDoug RabsonOnce you have built Heimdal and started the LDAP server, run kadmin 1124c19800e8SDoug Rabson(as usual) to initialise the database. Note that the instructions for 1125c19800e8SDoug Rabsonstashing a master key are as per any Heimdal installation. 1126c19800e8SDoug Rabson 1127c19800e8SDoug Rabson@example 1128c19800e8SDoug Rabsonkdc# kadmin -l 1129c19800e8SDoug Rabsonkadmin> init EXAMPLE.COM 1130c19800e8SDoug RabsonRealm max ticket life [unlimited]: 1131c19800e8SDoug RabsonRealm max renewable ticket life [unlimited]: 1132ae771770SStanislav Sedovkadmin> add lukeh 1133c19800e8SDoug RabsonMax ticket life [1 day]: 1134c19800e8SDoug RabsonMax renewable life [1 week]: 1135c19800e8SDoug RabsonPrincipal expiration time [never]: 1136c19800e8SDoug RabsonPassword expiration time [never]: 1137c19800e8SDoug RabsonAttributes []: 1138c19800e8SDoug Rabsonlukeh@@EXAMPLE.COM's Password: 1139c19800e8SDoug RabsonVerifying password - lukeh@@EXAMPLE.COM's Password: 1140c19800e8SDoug Rabsonkadmin> exit 1141c19800e8SDoug Rabson@end example 1142c19800e8SDoug Rabson 1143c19800e8SDoug RabsonVerify that the principal database has indeed been stored in the 1144c19800e8SDoug Rabsondirectory with the following command: 1145c19800e8SDoug Rabson 1146c19800e8SDoug Rabson@example 1147c19800e8SDoug Rabsonkdc# ldapsearch -L -h localhost -D cn=manager \ 1148c19800e8SDoug Rabson -w secret -b ou=KerberosPrincipals,dc=example,dc=com \ 1149c19800e8SDoug Rabson 'objectclass=krb5KDCEntry' 1150c19800e8SDoug Rabson@end example 1151c19800e8SDoug Rabson 1152c19800e8SDoug Rabson@item 1153c19800e8SDoug RabsonNow consider adding indexes to the database to speed up the access, at 1154c19800e8SDoug Rabsonleast theses should be added to slapd.conf. 1155c19800e8SDoug Rabson 1156c19800e8SDoug Rabson@example 1157c19800e8SDoug Rabsonindex objectClass eq 1158c19800e8SDoug Rabsonindex cn eq,sub,pres 1159c19800e8SDoug Rabsonindex uid eq,sub,pres 1160c19800e8SDoug Rabsonindex displayName eq,sub,pres 1161c19800e8SDoug Rabsonindex krb5PrincipalName eq 1162c19800e8SDoug Rabson@end example 1163c19800e8SDoug Rabson 1164c19800e8SDoug Rabson@end itemize 1165c19800e8SDoug Rabson 1166ae771770SStanislav Sedov@subsection smbk5pwd overlay 1167ae771770SStanislav Sedov 1168ae771770SStanislav SedovThe smbk5pwd overlay, updates the krb5Key and krb5KeyVersionNumber 1169ae771770SStanislav Sedovappropriately when it receives an LDAP Password change Extended 1170ae771770SStanislav SedovOperation: 1171ae771770SStanislav Sedov 1172ae771770SStanislav Sedov@url{http://www.openldap.org/devel/cvsweb.cgi/contrib/slapd-modules/smbk5pwd/README?hideattic=1&sortbydate=0} 1173ae771770SStanislav Sedov 1174c19800e8SDoug Rabson@subsection Troubleshooting guide 1175c19800e8SDoug Rabson 1176c19800e8SDoug Rabson@url{https://sec.miljovern.no/bin/view/Info/TroubleshootingGuide} 1177c19800e8SDoug Rabson 1178c19800e8SDoug Rabson 1179c19800e8SDoug Rabson@subsection Using Samba LDAP password database 1180c19800e8SDoug Rabson@cindex Samba 1181c19800e8SDoug Rabson 1182c19800e8SDoug Rabson@c @node Using Samba LDAP password database, Providing Kerberos credentials to servers and programs, Using LDAP to store the database, Setting up a realm 1183c19800e8SDoug Rabson@c @section Using Samba LDAP password database 1184c19800e8SDoug Rabson 1185c19800e8SDoug RabsonThe Samba domain and the Kerberos realm can have different names since 1186c19800e8SDoug Rabsonarcfour's string to key functions principal/realm independent. So now 1187c19800e8SDoug Rabsonwill be your first and only chance name your Kerberos realm without 1188c19800e8SDoug Rabsonneeding to deal with old configuration files. 1189c19800e8SDoug Rabson 1190c19800e8SDoug RabsonFirst, you should set up Samba and get that working with LDAP backend. 1191c19800e8SDoug Rabson 1192c19800e8SDoug RabsonNow you can proceed as in @xref{Using LDAP to store the database}. 1193c19800e8SDoug RabsonHeimdal will pick up the Samba LDAP entries if they are in the same 1194c19800e8SDoug Rabsonsearch space as the Kerberos entries. 1195c19800e8SDoug Rabson 1196c19800e8SDoug Rabson@node Providing Kerberos credentials to servers and programs, Setting up PK-INIT, Using LDAP to store the database, Setting up a realm 1197c19800e8SDoug Rabson@section Providing Kerberos credentials to servers and programs 1198c19800e8SDoug Rabson 1199c19800e8SDoug RabsonSome services require Kerberos credentials when they start to make 1200c19800e8SDoug Rabsonconnections to other services or need to use them when they have started. 1201c19800e8SDoug Rabson 1202c19800e8SDoug RabsonThe easiest way to get tickets for a service is to store the key in a 1203c19800e8SDoug Rabsonkeytab. Both ktutil get and kadmin ext can be used to get a 1204c19800e8SDoug Rabsonkeytab. ktutil get is better in that way it changes the key/password 1205c19800e8SDoug Rabsonfor the user. This is also the problem with ktutil. If ktutil is used 1206c19800e8SDoug Rabsonfor the same service principal on several hosts, they keytab will only 1207c19800e8SDoug Rabsonbe useful on the last host. In that case, run the extract command on 1208c19800e8SDoug Rabsonone host and then securely copy the keytab around to all other hosts 1209c19800e8SDoug Rabsonthat need it. 1210c19800e8SDoug Rabson 1211c19800e8SDoug Rabson@example 1212c19800e8SDoug Rabsonhost# ktutil -k /etc/krb5-service.keytab \ 1213c19800e8SDoug Rabson get -p lha/admin@@EXAMPLE.ORG service-principal@@EXAMPLE.ORG 1214c19800e8SDoug Rabsonlha/admin@@EXAMPLE.ORG's Password: 1215c19800e8SDoug Rabson@end example 1216c19800e8SDoug Rabson 1217c19800e8SDoug RabsonTo get a Kerberos credential file for the service, use kinit in the 1218c19800e8SDoug Rabson@kbd{--keytab} mode. This will not ask for a password but instead fetch the 1219c19800e8SDoug Rabsonkey from the keytab. 1220c19800e8SDoug Rabson 1221c19800e8SDoug Rabson@example 1222c19800e8SDoug Rabsonservice@@host$ kinit --cache=/var/run/service_krb5_cache \ 1223c19800e8SDoug Rabson --keytab=/etc/krb5-service.keytab \ 1224c19800e8SDoug Rabson service-principal@@EXAMPLE.ORG 1225c19800e8SDoug Rabson@end example 1226c19800e8SDoug Rabson 1227c19800e8SDoug RabsonLong running services might need credentials longer then the 1228c19800e8SDoug Rabsonexpiration time of the tickets. kinit can run in a mode that refreshes 1229c19800e8SDoug Rabsonthe tickets before they expire. This is useful for services that write 1230c19800e8SDoug Rabsoninto AFS and other distributed file systems using Kerberos. To run the 1231c19800e8SDoug Rabsonlong running script, just append the program and arguments (if any) 1232c19800e8SDoug Rabsonafter the principal. kinit will stop refreshing credentials and remove 1233c19800e8SDoug Rabsonthe credentials when the script-to-start-service exits. 1234c19800e8SDoug Rabson 1235c19800e8SDoug Rabson@example 1236c19800e8SDoug Rabsonservice@@host$ kinit --cache=/var/run/service_krb5_cache \ 1237c19800e8SDoug Rabson --keytab=/etc/krb5-service.keytab \ 1238c19800e8SDoug Rabson service-principal@@EXAMPLE.ORG \ 1239c19800e8SDoug Rabson script-to-start-service argument1 argument2 1240c19800e8SDoug Rabson@end example 1241c19800e8SDoug Rabson 1242c19800e8SDoug Rabson 1243ae771770SStanislav Sedov@node Setting up PK-INIT, Debugging Kerberos problems, Providing Kerberos credentials to servers and programs, Setting up a realm 1244c19800e8SDoug Rabson@section Setting up PK-INIT 1245c19800e8SDoug Rabson 1246ae771770SStanislav SedovPK-INIT leverages an existing PKI (public key infrastructure), using 1247ae771770SStanislav Sedovcertificates to get the initial ticket (usually the krbtgt 1248ae771770SStanislav Sedovticket-granting ticket). 1249c19800e8SDoug Rabson 1250ae771770SStanislav SedovTo use PK-INIT you must first have a PKI. If you don't have one, it is 1251ae771770SStanislav Sedovtime to create it. You should first read the whole chapter of the 1252ae771770SStanislav Sedovdocument to see the requirements imposed on the CA software. 1253c19800e8SDoug Rabson 1254ae771770SStanislav SedovA mapping between the PKI certificate and what principals that 1255ae771770SStanislav Sedovcertificate is allowed to use must exist. There are several ways to do 1256ae771770SStanislav Sedovthis. The administrator can use a configuration file, store the 1257ae771770SStanislav Sedovprincipal in the SubjectAltName extension of the certificate, or store 1258ae771770SStanislav Sedovthe mapping in the principals entry in the kerberos database. 1259c19800e8SDoug Rabson 1260c19800e8SDoug Rabson@section Certificates 1261c19800e8SDoug Rabson 1262c19800e8SDoug RabsonThis section documents the requirements on the KDC and client 1263c19800e8SDoug Rabsoncertificates and the format used in the id-pkinit-san OtherName 1264c19800e8SDoug Rabsonextention. 1265c19800e8SDoug Rabson 1266c19800e8SDoug Rabson@subsection KDC certificate 1267c19800e8SDoug Rabson 1268ae771770SStanislav SedovThe certificate for the KDC has serveral requirements. 1269c19800e8SDoug Rabson 1270ae771770SStanislav SedovFirst, the certificate should have an Extended Key Usage (EKU) 1271ae771770SStanislav Sedovid-pkkdcekuoid (1.3.6.1.5.2.3.5) set. Second, there must be a 1272ae771770SStanislav SedovsubjectAltName otherName using OID id-pkinit-san (1.3.6.1.5.2.2) in 1273c19800e8SDoug Rabsonthe type field and a DER encoded KRB5PrincipalName that matches the 1274ae771770SStanislav Sedovname of the TGS of the target realm. Also, if the certificate has a 1275ae771770SStanislav SedovnameConstraints extention with a Generalname with dNSName or iPAdress, 1276ae771770SStanislav Sedovit must match the hostname or adress of the KDC. 1277c19800e8SDoug Rabson 1278ae771770SStanislav SedovThe client is not required by the standard to check the server 1279ae771770SStanislav Sedovcertificate for this information if the client has external 1280ae771770SStanislav Sedovinformation confirming which certificate the KDC is supposed to be 1281ae771770SStanislav Sedovusing. However, adding this information to the KDC certificate removes 1282ae771770SStanislav Sedovthe need to specially configure the client to recognize the KDC 1283ae771770SStanislav Sedovcertificate. 1284c19800e8SDoug Rabson 1285c19800e8SDoug RabsonRemember that if the client would accept any certificate as the KDC's 1286c19800e8SDoug Rabsoncertificate, the client could be fooled into trusting something that 1287c19800e8SDoug Rabsonisn't a KDC and thus expose the user to giving away information (like 1288ae771770SStanislav Sedova password or other private information) that it is supposed to keep 1289ae771770SStanislav Sedovsecret. 1290c19800e8SDoug Rabson 1291c19800e8SDoug Rabson@subsection Client certificate 1292c19800e8SDoug Rabson 1293c19800e8SDoug RabsonThe client certificate may need to have a EKU id-pkekuoid 1294c19800e8SDoug Rabson(1.3.6.1.5.2.3.4) set depending on the certifiate on the KDC. 1295c19800e8SDoug Rabson 1296c19800e8SDoug RabsonIt possible to store the principal (if allowed by the KDC) in the 1297c19800e8SDoug Rabsoncertificate and thus delegate responsibility to do the mapping between 1298c19800e8SDoug Rabsoncertificates and principals to the CA. 1299c19800e8SDoug Rabson 1300ae771770SStanislav SedovThis behavior is controlled by KDC configuration option: 1301ae771770SStanislav Sedov 1302ae771770SStanislav Sedov@example 1303ae771770SStanislav Sedov[kdc] 1304ae771770SStanislav Sedov pkinit_principal_in_certificate = yes 1305ae771770SStanislav Sedov@end example 1306ae771770SStanislav Sedov 1307c19800e8SDoug Rabson@subsubsection Using KRB5PrincipalName in id-pkinit-san 1308c19800e8SDoug Rabson 1309ae771770SStanislav SedovThe OtherName extention in the GeneralName is used to do the mapping 1310ae771770SStanislav Sedovbetween certificate and principal. For the KDC certificate, this 1311ae771770SStanislav Sedovstores the krbtgt principal name for that KDC. For the client 1312ae771770SStanislav Sedovcertificate, this stores the principal for which that certificate is 1313ae771770SStanislav Sedovallowed to get tickets. 1314c19800e8SDoug Rabson 1315c19800e8SDoug RabsonThe principal is stored in a SubjectAltName in the certificate using 1316ae771770SStanislav SedovOtherName. The OID in the type is id-pkinit-san. 1317c19800e8SDoug Rabson 1318c19800e8SDoug Rabson@example 1319c19800e8SDoug Rabsonid-pkinit-san OBJECT IDENTIFIER ::= @{ iso (1) org (3) dod (6) 1320c19800e8SDoug Rabsoninternet (1) security (5) kerberosv5 (2) 2 @} 1321c19800e8SDoug Rabson@end example 1322c19800e8SDoug Rabson 1323c19800e8SDoug RabsonThe data part of the OtherName is filled with the following DER 1324c19800e8SDoug Rabsonencoded ASN.1 structure: 1325c19800e8SDoug Rabson 1326c19800e8SDoug Rabson@example 1327c19800e8SDoug RabsonKRB5PrincipalName ::= SEQUENCE @{ 1328c19800e8SDoug Rabson realm [0] Realm, 1329c19800e8SDoug Rabson principalName [1] PrincipalName 1330c19800e8SDoug Rabson@} 1331c19800e8SDoug Rabson@end example 1332c19800e8SDoug Rabson 1333ae771770SStanislav Sedovwhere Realm and PrincipalName is defined by the Kerberos ASN.1 1334ae771770SStanislav Sedovspecification. 1335c19800e8SDoug Rabson 1336c19800e8SDoug Rabson@section Naming certificate using hx509 1337c19800e8SDoug Rabson 1338c19800e8SDoug Rabsonhx509 is the X.509 software used in Heimdal to handle 1339ae771770SStanislav Sedovcertificates. hx509 supports several different syntaxes for specifying 1340ae771770SStanislav Sedovcertificate files or formats. Several formats may be used: PEM, 1341ae771770SStanislav Sedovcertificates embedded in PKCS#12 files, certificates embedded in 1342ae771770SStanislav SedovPKCS#11 devices, and raw DER encoded certificates. 1343c19800e8SDoug Rabson 1344ae771770SStanislav SedovThose formats may be specified as follows: 1345c19800e8SDoug Rabson 1346c19800e8SDoug Rabson@table @asis 1347c19800e8SDoug Rabson 1348c19800e8SDoug Rabson@item DIR: 1349c19800e8SDoug Rabson 1350ae771770SStanislav SedovDIR specifies a directory which contains certificates in the DER or 1351ae771770SStanislav SedovPEM format. 1352c19800e8SDoug Rabson 1353c19800e8SDoug RabsonThe main feature of DIR is that the directory is read on demand when 1354ae771770SStanislav Sedoviterating over certificates. This allows applications, in some 1355ae771770SStanislav Sedovsituations, to avoid having to store all certificates in memory. It's 1356ae771770SStanislav Sedovvery useful for tests that iterate over large numbers of certificates. 1357c19800e8SDoug Rabson 1358ae771770SStanislav SedovThe syntax is: 1359c19800e8SDoug Rabson 1360c19800e8SDoug Rabson@example 1361c19800e8SDoug RabsonDIR:/path/to/der/files 1362c19800e8SDoug Rabson@end example 1363c19800e8SDoug Rabson 1364c19800e8SDoug Rabson@item FILE: 1365c19800e8SDoug Rabson 1366ae771770SStanislav SedovFILE: specifies a file that contains a certificate or private key. 1367ae771770SStanislav SedovThe file can be either a PEM (openssl) file or a raw DER encoded 1368ae771770SStanislav Sedovcertificate. If it's a PEM file, it can contain several keys and 1369c19800e8SDoug Rabsoncertificates and the code will try to match the private key and 1370ae771770SStanislav Sedovcertificate together. Multiple files may be specified, separated by 1371ae771770SStanislav Sedovcommas. 1372c19800e8SDoug Rabson 1373ae771770SStanislav SedovIt's useful to have one PEM file that contains all the trust anchors. 1374c19800e8SDoug Rabson 1375ae771770SStanislav SedovThe syntax is: 1376c19800e8SDoug Rabson 1377c19800e8SDoug Rabson@example 1378c19800e8SDoug RabsonFILE:certificate.pem,private-key.key,other-cert.pem,.... 1379c19800e8SDoug Rabson@end example 1380c19800e8SDoug Rabson 1381c19800e8SDoug Rabson@item PKCS11: 1382c19800e8SDoug Rabson 1383ae771770SStanislav SedovPKCS11: is used to handle smartcards via PKCS#11 drivers, such as 1384ae771770SStanislav Sedovsoft-token, opensc, or muscle. The argument specifies a shared object 1385ae771770SStanislav Sedovthat implements the PKCS#11 API. The default is to use all slots on 1386ae771770SStanislav Sedovthe device/token. 1387c19800e8SDoug Rabson 1388ae771770SStanislav SedovThe syntax is: 1389c19800e8SDoug Rabson 1390c19800e8SDoug Rabson@example 1391c19800e8SDoug RabsonPKCS11:shared-object.so 1392c19800e8SDoug Rabson@end example 1393c19800e8SDoug Rabson 1394c19800e8SDoug Rabson@item PKCS12: 1395c19800e8SDoug Rabson 1396ae771770SStanislav SedovPKCS12: is used to handle PKCS#12 files. PKCS#12 files commonly have 1397ae771770SStanislav Sedovthe extension pfx or p12. 1398c19800e8SDoug Rabson 1399ae771770SStanislav SedovThe syntax is: 1400c19800e8SDoug Rabson 1401c19800e8SDoug Rabson@example 1402c19800e8SDoug RabsonPKCS12:/path/to/file.pfx 1403c19800e8SDoug Rabson@end example 1404c19800e8SDoug Rabson 1405c19800e8SDoug Rabson@end table 1406c19800e8SDoug Rabson 1407c19800e8SDoug Rabson@section Configure the Kerberos software 1408c19800e8SDoug Rabson 1409c19800e8SDoug RabsonFirst configure the client's trust anchors and what parameters to 1410ae771770SStanislav Sedovverify. See the subsections below for how to do that. Then, you can 1411ae771770SStanislav Sedovuse kinit to get yourself tickets. For example: 1412c19800e8SDoug Rabson 1413c19800e8SDoug Rabson@example 1414c19800e8SDoug Rabson$ kinit -C FILE:$HOME/.certs/lha.crt,$HOME/.certs/lha.key lha@@EXAMPLE.ORG 1415c19800e8SDoug RabsonEnter your private key passphrase: 1416c19800e8SDoug Rabson: lha@@nutcracker ; klist 1417c19800e8SDoug RabsonCredentials cache: FILE:/tmp/krb5cc_19100a 1418c19800e8SDoug Rabson Principal: lha@@EXAMPLE.ORG 1419c19800e8SDoug Rabson 1420c19800e8SDoug Rabson Issued Expires Principal 1421c19800e8SDoug RabsonApr 20 02:08:08 Apr 20 12:08:08 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG 1422c19800e8SDoug Rabson@end example 1423c19800e8SDoug Rabson 1424ae771770SStanislav SedovUsing PKCS#11 it can look like this instead: 1425c19800e8SDoug Rabson 1426c19800e8SDoug Rabson@example 1427ae771770SStanislav Sedov$ kinit -C PKCS11:/usr/heimdal/lib/hx509.so lha@@EXAMPLE.ORG 1428c19800e8SDoug RabsonPIN code for SoftToken (slot): 1429c19800e8SDoug Rabson$ klist 1430c19800e8SDoug RabsonCredentials cache: API:4 1431c19800e8SDoug Rabson Principal: lha@@EXAMPLE.ORG 1432c19800e8SDoug Rabson 1433c19800e8SDoug Rabson Issued Expires Principal 1434c19800e8SDoug RabsonMar 26 23:40:10 Mar 27 09:40:10 krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG 1435c19800e8SDoug Rabson@end example 1436c19800e8SDoug Rabson 1437ae771770SStanislav SedovTODO: Write about the KDC. 1438c19800e8SDoug Rabson 1439c19800e8SDoug Rabson@section Configure the client 1440c19800e8SDoug Rabson 1441c19800e8SDoug Rabson@example 1442c19800e8SDoug Rabson[appdefaults] 1443c19800e8SDoug Rabson pkinit_anchors = FILE:/path/to/trust-anchors.pem 1444c19800e8SDoug Rabson 1445c19800e8SDoug Rabson[realms] 1446c19800e8SDoug Rabson EXAMPLE.COM = @{ 1447c19800e8SDoug Rabson pkinit_require_eku = true 1448c19800e8SDoug Rabson pkinit_require_krbtgt_otherName = true 1449c19800e8SDoug Rabson pkinit_win2k = no 1450c19800e8SDoug Rabson pkinit_win2k_require_binding = yes 1451c19800e8SDoug Rabson @} 1452c19800e8SDoug Rabson 1453c19800e8SDoug Rabson@end example 1454c19800e8SDoug Rabson 1455c19800e8SDoug Rabson@section Configure the KDC 1456c19800e8SDoug Rabson 1457c19800e8SDoug Rabson@example 1458c19800e8SDoug Rabson[kdc] 1459c19800e8SDoug Rabson enable-pkinit = yes 1460c19800e8SDoug Rabson pkinit_identity = FILE:/secure/kdc.crt,/secure/kdc.key 1461c19800e8SDoug Rabson pkinit_anchors = FILE:/path/to/trust-anchors.pem 1462c19800e8SDoug Rabson pkinit_pool = PKCS12:/path/to/useful-intermediate-certs.pfx 1463c19800e8SDoug Rabson pkinit_pool = FILE:/path/to/other-useful-intermediate-certs.pem 1464ae771770SStanislav Sedov pkinit_allow_proxy_certificate = no 1465c19800e8SDoug Rabson pkinit_win2k_require_binding = yes 1466ae771770SStanislav Sedov pkinit_principal_in_certificate = no 1467c19800e8SDoug Rabson@end example 1468c19800e8SDoug Rabson 1469c19800e8SDoug Rabson@subsection Using pki-mapping file 1470c19800e8SDoug Rabson 1471c19800e8SDoug RabsonNote that the file name is space sensitive. 1472c19800e8SDoug Rabson 1473c19800e8SDoug Rabson@example 1474c19800e8SDoug Rabson# cat /var/heimdal/pki-mapping 1475c19800e8SDoug Rabson# comments starts with # 1476c19800e8SDoug Rabsonlha@@EXAMPLE.ORG:C=SE,O=Stockholm universitet,CN=Love,UID=lha 1477c19800e8SDoug Rabsonlha@@EXAMPLE.ORG:CN=Love,UID=lha 1478c19800e8SDoug Rabson@end example 1479c19800e8SDoug Rabson 1480c19800e8SDoug Rabson@subsection Using the Kerberos database 1481c19800e8SDoug Rabson 1482c19800e8SDoug Rabson@section Use hxtool to create certificates 1483c19800e8SDoug Rabson 1484c19800e8SDoug Rabson@subsection Generate certificates 1485c19800e8SDoug Rabson 1486ae771770SStanislav SedovFirst, you need to generate a CA certificate. This example creates a 1487ae771770SStanislav SedovCA certificate that will be valid for 10 years. 1488c19800e8SDoug Rabson 1489ae771770SStanislav SedovYou need to change --subject in the command below to something 1490ae771770SStanislav Sedovappropriate for your site. 1491c19800e8SDoug Rabson 1492c19800e8SDoug Rabson@example 1493c19800e8SDoug Rabsonhxtool issue-certificate \ 1494c19800e8SDoug Rabson --self-signed \ 1495c19800e8SDoug Rabson --issue-ca \ 1496c19800e8SDoug Rabson --generate-key=rsa \ 1497c19800e8SDoug Rabson --subject="CN=CA,DC=test,DC=h5l,DC=se" \ 1498c19800e8SDoug Rabson --lifetime=10years \ 1499c19800e8SDoug Rabson --certificate="FILE:ca.pem" 1500c19800e8SDoug Rabson@end example 1501c19800e8SDoug Rabson 1502c19800e8SDoug RabsonThe KDC needs to have a certificate, so generate a certificate of the 1503c19800e8SDoug Rabsontype ``pkinit-kdc'' and set the PK-INIT specifial SubjectAltName to the 1504c19800e8SDoug Rabsonname of the krbtgt of the realm. 1505c19800e8SDoug Rabson 1506ae771770SStanislav SedovYou need to change --subject and --pk-init-principal in the command 1507ae771770SStanislav Sedovbelow to something appropriate for your site. 1508c19800e8SDoug Rabson 1509c19800e8SDoug Rabson@example 1510c19800e8SDoug Rabsonhxtool issue-certificate \ 1511c19800e8SDoug Rabson --ca-certificate=FILE:ca.pem \ 1512c19800e8SDoug Rabson --generate-key=rsa \ 1513c19800e8SDoug Rabson --type="pkinit-kdc" \ 1514c19800e8SDoug Rabson --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \ 1515c19800e8SDoug Rabson --subject="uid=kdc,DC=test,DC=h5l,DC=se" \ 1516c19800e8SDoug Rabson --certificate="FILE:kdc.pem" 1517c19800e8SDoug Rabson@end example 1518c19800e8SDoug Rabson 1519ae771770SStanislav SedovThe users also needs to have certificates. For your first client, 1520ae771770SStanislav Sedovgenerate a certificate of type ``pkinit-client''. The client doesn't 1521ae771770SStanislav Sedovneed to have the PK-INIT SubjectAltName set; you can have the Subject 1522ae771770SStanislav SedovDN in the ACL file (pki-mapping) instead. 1523c19800e8SDoug Rabson 1524ae771770SStanislav SedovYou need to change --subject and --pk-init-principal in the command 1525ae771770SStanislav Sedovbelow to something appropriate for your site. You can omit 1526ae771770SStanislav Sedov--pk-init-principal if you're going to use the ACL file instead. 1527c19800e8SDoug Rabson 1528c19800e8SDoug Rabson@example 1529c19800e8SDoug Rabsonhxtool issue-certificate \ 1530c19800e8SDoug Rabson --ca-certificate=FILE:ca.pem \ 1531c19800e8SDoug Rabson --generate-key=rsa \ 1532c19800e8SDoug Rabson --type="pkinit-client" \ 1533c19800e8SDoug Rabson --pk-init-principal="lha@@TEST.H5L.SE" \ 1534c19800e8SDoug Rabson --subject="uid=lha,DC=test,DC=h5l,DC=se" \ 1535c19800e8SDoug Rabson --certificate="FILE:user.pem" 1536c19800e8SDoug Rabson@end example 1537c19800e8SDoug Rabson 1538c19800e8SDoug Rabson@subsection Validate the certificate 1539c19800e8SDoug Rabson 1540ae771770SStanislav Sedovhxtool also contains a tool that will validate certificates according 1541ae771770SStanislav Sedovto rules from the PKIX document. These checks are not complete, but 1542ae771770SStanislav Sedovthey provide a good test of whether you got all of the basic bits 1543ae771770SStanislav Sedovright in your certificates. 1544c19800e8SDoug Rabson 1545c19800e8SDoug Rabson@example 1546c19800e8SDoug Rabsonhxtool validate FILE:user.pem 1547c19800e8SDoug Rabson@end example 1548c19800e8SDoug Rabson 1549c19800e8SDoug Rabson@section Use OpenSSL to create certificates 1550c19800e8SDoug Rabson 1551c19800e8SDoug RabsonThis section tries to give the CA owners hints how to create 1552c19800e8SDoug Rabsoncertificates using OpenSSL (or CA software based on OpenSSL). 1553c19800e8SDoug Rabson 1554c19800e8SDoug Rabson@subsection Using OpenSSL to create certificates with krb5PrincipalName 1555c19800e8SDoug Rabson 1556ae771770SStanislav SedovTo make OpenSSL create certificates with krb5PrincipalName, use an 1557c19800e8SDoug Rabson@file{openssl.cnf} as described below. To see a complete example of 1558c19800e8SDoug Rabsoncreating client and KDC certificates, see the test-data generation 1559c19800e8SDoug Rabsonscript @file{lib/hx509/data/gen-req.sh} in the source-tree. The 1560c19800e8SDoug Rabsoncerticates it creates are used to test the PK-INIT functionality in 1561c19800e8SDoug Rabson@file{tests/kdc/check-kdc.in}. 1562c19800e8SDoug Rabson 1563c19800e8SDoug RabsonTo use this example you have to use OpenSSL 0.9.8a or later. 1564c19800e8SDoug Rabson 1565c19800e8SDoug Rabson@example 1566c19800e8SDoug Rabson 1567c19800e8SDoug Rabson[user_certificate] 1568c19800e8SDoug RabsonsubjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:princ_name 1569c19800e8SDoug Rabson 1570c19800e8SDoug Rabson[princ_name] 1571c19800e8SDoug Rabsonrealm = EXP:0, GeneralString:MY.REALM 1572c19800e8SDoug Rabsonprincipal_name = EXP:1, SEQUENCE:principal_seq 1573c19800e8SDoug Rabson 1574c19800e8SDoug Rabson[principal_seq] 1575c19800e8SDoug Rabsonname_type = EXP:0, INTEGER:1 1576c19800e8SDoug Rabsonname_string = EXP:1, SEQUENCE:principals 1577c19800e8SDoug Rabson 1578c19800e8SDoug Rabson[principals] 1579c19800e8SDoug Rabsonprinc1 = GeneralString:userid 1580c19800e8SDoug Rabson 1581c19800e8SDoug Rabson@end example 1582c19800e8SDoug Rabson 1583ae771770SStanislav SedovCommand usage: 1584c19800e8SDoug Rabson 1585c19800e8SDoug Rabson@example 1586c19800e8SDoug Rabsonopenssl x509 -extensions user_certificate 1587c19800e8SDoug Rabsonopenssl ca -extensions user_certificate 1588c19800e8SDoug Rabson@end example 1589c19800e8SDoug Rabson 1590c19800e8SDoug Rabson 1591c19800e8SDoug Rabson@c --- ms certificate 1592c19800e8SDoug Rabson@c 1593c19800e8SDoug Rabson@c [ new_oids ] 1594c19800e8SDoug Rabson@c msCertificateTemplateName = 1.3.6.1.4.1.311.20.2 1595c19800e8SDoug Rabson@c 1596c19800e8SDoug Rabson@c 1597c19800e8SDoug Rabson@c [ req_smartcard ] 1598c19800e8SDoug Rabson@c keyUsage = digitalSignature, keyEncipherment 1599c19800e8SDoug Rabson@c extendedKeyUsage = msSmartcardLogin, clientAuth 1600c19800e8SDoug Rabson@c msCertificateTemplateName = ASN1:BMP:SmartcardLogon 1601c19800e8SDoug Rabson@c subjectAltName = otherName:msUPN;UTF8:lukeh@dsg.padl.com 1602c19800e8SDoug Rabson@c #subjectAltName = email:copy 1603c19800e8SDoug Rabson 1604c19800e8SDoug Rabson 1605c19800e8SDoug Rabson@section Using PK-INIT with Windows 1606c19800e8SDoug Rabson 1607c19800e8SDoug Rabson@subsection Client configration 1608c19800e8SDoug Rabson 1609c19800e8SDoug RabsonClients using a Windows KDC with PK-INIT need configuration since 1610c19800e8SDoug Rabsonwindows uses pre-standard format and this can't be autodetected. 1611c19800e8SDoug Rabson 1612c19800e8SDoug RabsonThe pkinit_win2k_require_binding option requires the reply for the KDC 1613ae771770SStanislav Sedovto be of the new, secure, type that binds the request to 1614ae771770SStanislav Sedovreply. Before, clients could fake the reply from the KDC. To use this 1615ae771770SStanislav Sedovoption you have to apply a fix from Microsoft. 1616c19800e8SDoug Rabson 1617c19800e8SDoug Rabson@example 1618c19800e8SDoug Rabson[realms] 1619c19800e8SDoug Rabson MY.MS.REALM = @{ 1620c19800e8SDoug Rabson pkinit_win2k = yes 1621c19800e8SDoug Rabson pkinit_win2k_require_binding = no 1622c19800e8SDoug Rabson @} 1623c19800e8SDoug Rabson@end example 1624c19800e8SDoug Rabson 1625c19800e8SDoug Rabson@subsection Certificates 1626c19800e8SDoug Rabson 1627c19800e8SDoug RabsonThe client certificates need to have the extended keyusage ``Microsoft 1628ae771770SStanislav SedovSmartcardlogin'' (openssl has the OID shortname msSmartcardLogin). 1629c19800e8SDoug Rabson 1630c19800e8SDoug RabsonSee Microsoft Knowledge Base Article - 281245 ``Guidelines for Enabling 1631c19800e8SDoug RabsonSmart Card Logon with Third-Party Certification Authorities'' for a 1632ae771770SStanislav Sedovmore extensive description of how set setup an external CA so that it 1633ae771770SStanislav Sedovincludes all the information required to make a Windows KDC happy. 1634c19800e8SDoug Rabson 1635c19800e8SDoug Rabson@subsection Configure Windows 2000 CA 1636c19800e8SDoug Rabson 1637ae771770SStanislav SedovTo enable Microsoft Smartcardlogin for certificates in your Windows 1638ae771770SStanislav Sedov2000 CA, you want to look at Microsoft Knowledge Base Article - 313274 1639ae771770SStanislav Sedov``HOW TO: Configure a Certification Authority to Issue Smart Card 1640ae771770SStanislav SedovCertificates in Windows''. 1641ae771770SStanislav Sedov 1642ae771770SStanislav Sedov@node Debugging Kerberos problems, , Setting up PK-INIT, Setting up a realm 1643ae771770SStanislav Sedov@section Debugging Kerberos problems 1644ae771770SStanislav Sedov 1645ae771770SStanislav SedovTo debug Kerberos client and server problems you can enable debug 1646ae771770SStanislav Sedovtraceing by adding the following to @file{/etc/krb5,conf}. Note that the 1647ae771770SStanislav Sedovtrace logging is sparse at the moment, but will continue to improve. 1648ae771770SStanislav Sedov 1649ae771770SStanislav Sedov@example 1650ae771770SStanislav Sedov[logging] 1651ae771770SStanislav Sedov libkrb5 = 0-/SYSLOG: 1652ae771770SStanislav Sedov@end example 1653ae771770SStanislav Sedov 1654ae771770SStanislav Sedov 1655ae771770SStanislav Sedov 1656ae771770SStanislav Sedov 1657