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