1=for stopwords 2KRB5CCNAME ChallengeResponseAuthentication GSS-API Heimdal KDC PKINIT 3PasswordAuthentication SRV Solaris Sourceforge aname appdefaults auth 4canonicalized ccache krb5.conf forwardable kdestroy keytab libdefaults 5logout pam-krb5 preauth 0.8rc1 screensaver screensavers sshd localname 6krb5.conf. 0.8rc1. Allbery Cusack Salomon FSFAP SPDX-License-Identifier 7responder 8 9=head1 NAME 10 11pam_krb5 - Kerberos PAM module 12 13=head1 SYNOPSIS 14 15 auth sufficient pam_krb5.so minimum_uid=1000 16 session required pam_krb5.so minimum_uid=1000 17 account required pam_krb5.so minimum_uid=1000 18 password sufficient pam_krb5.so minimum_uid=1000 19 20=head1 DESCRIPTION 21 22The Kerberos service module for PAM, typically installed at 23F</lib/security/pam_krb5.so>, provides functionality for the four PAM 24operations: authentication, account management, session management, and 25password management. F<pam_krb5.so> is a shared object that is 26dynamically loaded by the PAM subsystem as necessary, based on the system 27PAM configuration. PAM is a system for plugging in external 28authentication and session management modules so that each application 29doesn't have to know the best way to check user authentication or create a 30user session on that system. For details on how to configure PAM on your 31system, see the PAM man page, often pam(7). 32 33Here are the actions of this module when called from each group: 34 35=over 4 36 37=item auth 38 39Provides implementations of pam_authenticate() and pam_setcred(). The 40former takes the username from the PAM session, prompts for the user's 41password (unless configured to use an already-entered password), and then 42performs a Kerberos initial authentication, storing the obtained 43credentials (if successful) in a temporary ticket cache. The latter, 44depending on the flags it is called with, either takes the contents of the 45temporary ticket cache and writes it out to a persistent ticket cache 46owned by the user or uses the temporary ticket cache to refresh an 47existing user ticket cache. 48 49Passwords as long or longer than PAM_MAX_RESP_SIZE octets (normally 512 50octets) will be rejected, since excessively long passwords can be used as 51a denial of service attack. 52 53After doing the initial authentication, the Kerberos PAM module will 54attempt to obtain tickets for a key in the local system keytab and then 55verify those tickets. Unless this step is performed, the authentication 56is vulnerable to KDC spoofing, but it requires that the system have a 57local key and that the PAM module be running as a user that can read the 58keytab file (normally F</etc/krb5.keytab>. You can point the Kerberos PAM 59module at a different keytab with the I<keytab> option. If that keytab 60cannot be read or if no keys are found in it, the default behavior is to 61fail authentication. If you want to skip this check, set the 62C<allow_kdc_spoof> option to true either in the [appdefaults] section of 63F</etc/krb5.conf> or in the PAM policy. 64 65By default, whenever the user is authenticated, a basic authorization 66check will also be done using krb5_kuserok(). The default behavior of 67this function is to check the user's account for a F<.k5login> file and, 68if one is present, ensure that the user's principal is listed in that 69file. If F<.k5login> is not present, the default check is to ensure that 70the user's principal is in the default local realm and the user portion of 71the principal matches the account name (this can be changed by configuring 72a custom aname to localname mapping in F<krb5.conf>; see the Kerberos 73documentation for details). This can be customized with several 74configuration options; see below. 75 76If the username provided to PAM contains an C<@> and Kerberos can, 77treating the username as a principal, map it to a local account name, 78pam_authenticate() will change the PAM user to that local account name. 79This allows users to log in with their Kerberos principal and let Kerberos 80do the mapping to an account. This can be disabled with the 81I<no_update_user> option. Be aware, however, that this facility cannot be 82used with OpenSSH. OpenSSH will reject usernames that don't match local 83accounts before this remapping can be done and will pass an invalid 84password to the PAM module. Also be aware that several other common PAM 85modules, such as pam_securetty, expect to be able to look up the user with 86getpwnam() and cannot be called before pam_krb5 when using this feature. 87 88When pam_setcred() is called to initialize a new ticket cache, the 89environment variable KRB5CCNAME is set to the path to that ticket cache. 90By default, the cache will be named F</tmp/krb5cc_UID_RANDOM> where UID is 91the user's UID and RANDOM is six randomly-chosen letters. This can be 92configured with the I<ccache> and I<ccache_dir> options. 93 94pam-krb5 does not use the default ticket cache location or 95I<default_cc_name> in the C<[libdefaults]> section of F<krb5.conf>. The 96default cache location would share a cache for all sessions of the same 97user, which causes confusing behavior when the user logs out of one of 98multiple sessions. 99 100If pam_setcred() initializes a new ticket cache, it will also set up that 101ticket cache so that it will be deleted when the PAM session is closed. 102Normally, the calling program (B<login>, B<sshd>, etc.) will run the 103user's shell as a sub-process, wait for it to exit, and then close the PAM 104session, thereby cleaning up the user's session. 105 106=item session 107 108Provides implementations of pam_open_session(), which is equivalent to 109calling pam_setcred() with the PAM_ESTABLISH_CRED flag, and 110pam_close_session(), which destroys the ticket cache created by 111pam_setcred(). 112 113=item account 114 115Provides an implementation of pam_acct_mgmt(). All it does is do the same 116authorization check as performed by the pam_authenticate() implementation 117described above. 118 119=item password 120 121Provides an implementation of pam_chauthtok(), which implements password 122changes. The user is prompted for their existing password (unless 123configured to use an already entered one) and the PAM module then obtains 124credentials for the special Kerberos principal C<kadmin/changepw>. It 125then prompts the user for a new password, twice to ensure that the user 126entered it properly (again, unless configured to use an already entered 127password), and then does a Kerberos password change. 128 129Passwords as long or longer than PAM_MAX_RESP_SIZE octets (normally 512 130octets) will be rejected, since excessively long passwords can be used as 131a denial of service attack. 132 133Unlike the normal Unix password module, this module will allow any user to 134change any other user's password if they know the old password. Also, 135unlike the normal Unix password module, root will always be prompted for 136the old password, since root has no special status in Kerberos. (To 137change passwords in Kerberos without knowing the old password, use 138kadmin(8) instead.) 139 140=back 141 142Both the account and session management calls of the Kerberos PAM module 143will return PAM_IGNORE if called in the context of a PAM session for a 144user who did not authenticate with Kerberos (a return code of C<ignore> in 145the Linux PAM configuration language). 146 147Note that this module assumes the network is available in order to do a 148Kerberos authentication. If the network is not available, some Kerberos 149libraries have timeouts longer than the timeout imposed by the login 150process. This means that using this module incautiously can make it 151impossible to log on to console as root. For this reason, you should 152always use the I<ignore_root> or I<minimum_uid> options, list a local 153authentication module such as B<pam_unix> first with a control field of 154C<sufficient> so that the Kerberos PAM module will be skipped if local 155password authentication was successful. 156 157This is not the same PAM module as the Kerberos PAM module available from 158Sourceforge, or the one included on Red Hat systems. It supports many of 159the same options, has some additional options, and doesn't support some of 160the options those modules do. 161 162=head1 CONFIGURATION 163 164The Kerberos PAM module takes many options, not all of which are relevant 165to every PAM group; options that are not relevant will be silently 166ignored. Any of these options can be set in the PAM configuration as 167arguments listed after C<pam_krb5.so>. Some of the options can also be 168set in the system F<krb5.conf> file; if this is possible, it will be noted 169below in the option description. 170 171To set a boolean option in the PAM configuration file, just give the name 172of the option in the arguments. To set an option that takes an argument, 173follow the option name with an equal sign (=) and the value, with no 174separating whitespace. Whitespace in option arguments is not supported in 175the PAM configuration. 176 177To set an option for the PAM module in the system F<krb5.conf> file, put 178that option in the C<[appdefaults]> section. All options must be followed 179by an equal sign (=) and a value, so for boolean options add C<= true>. 180The Kerberos PAM module will look for options either at the top level of 181the C<[appdefaults]> section or in a subsection named C<pam>, inside or 182outside a section for the realm. For example, the following fragment of a 183F<krb5.conf> file would set I<forwardable> to true, I<minimum_uid> to 1841000, and set I<ignore_k5login> only if the realm is EXAMPLE.COM. 185 186 [appdefaults] 187 forwardable = true 188 pam = { 189 minimum_uid = 1000 190 EXAMPLE.COM = { 191 ignore_k5login = true 192 } 193 } 194 195For more information on the syntax of F<krb5.conf>, see krb5.conf(5). 196Note that options that depend on the realm will be set only on the basis 197of the default realm, either as configured in krb5.conf(5) or as set by 198the I<realm> option described below. If the user authenticates to an 199account qualified with a realm, that realm will not be used when 200determining which options will apply. 201 202There is no difference to the PAM module whether options are specified at 203the top level or in a C<pam> section; the C<pam> section is supported in 204case there are options that should be set for the PAM module but not for 205other applications. 206 207If the same option is set in F<krb5.conf> and in the PAM configuration, 208the latter takes precedent. Note, however, that due to the configuration 209syntax, there's no way to turn off a boolean option in the PAM 210configuration that was turned on in F<krb5.conf>. 211 212The start of each option description is annotated with the version of 213pam-krb5 in which that option was added with the current meaning. 214 215=head2 Authorization 216 217=over 4 218 219=item allow_kdc_spoof 220 221Allow authentication to succeed even if there is no host or service 222key available in a keytab to authenticate the Kerberos KDC's ticket. 223 224=item alt_auth_map=<format> 225 226[3.12] This functions similarly to the I<search_k5login> option. The 227<format> argument is used as the authentication Kerberos principal, with 228any C<%s> in <format> replaced with the username. If the username 229contains an C<@>, only the part of the username before the realm is used 230to replace C<%s>. If <format> contains a realm, it will be used; 231otherwise, the realm of the username (if any) will be appended to the 232result. There is no quote removal. 233 234If this option is present, the default behavior is to try this alternate 235principal first and then fall back to the standard behavior if it fails. 236The primary usage is to allow alternative principals to be used for 237authentication in programs like B<sudo>. Most examples will look like: 238 239 alt_auth_map=%s/root 240 241which attempts authentication as the root instance of the username first 242and then falls back to the regular username (but see I<force_alt_auth> and 243I<only_alt_auth>). 244 245This option also allows a cheap way to attempt authentication in an 246alternative realm first and then fall back to the primary realm. A 247setting like: 248 249 alt_auth_map=%s@EXAMPLE.COM 250 251will attempt authentication in the EXAMPLE.COM realm first and then fall 252back on the local default realm. This is more convenient than running the 253module multiple times with multiple default realms set with I<realm>, but 254it is very limited: only two realms can be tried, and the alternate realm 255is always tried first. 256 257This option can be set in C<[appdefaults]> in F<krb5.conf>, although 258normally it doesn't make sense to do that; normally it is used in the PAM 259options of configuration for specific programs. It is only applicable to 260the auth and account groups. If this option is set for the auth group, be 261sure to set it for the account group as well or account authorization may 262fail. 263 264=item force_alt_auth 265 266[3.12] This option is used with I<alt_auth_map> and forces authentication 267as the mapped principal if that principal exists in the KDC. Only if the 268KDC returns principal unknown does the Kerberos PAM module fall back to 269normal authentication. This can be used to force authentication with an 270alternate instance. If I<alt_auth_map> is not set, it has no effect. 271 272This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 273applicable to the auth group. 274 275=item ignore_k5login 276 277[2.0] Never look for a F<.k5login> file in the user's home directory. 278Instead, only check that the Kerberos principal maps to the local account 279name. The default check is to ensure the realm matches the local realm 280and the user portion of the principal matches the local account name, but 281this can be customized by setting up an aname to localname mapping in 282F<krb5.conf>. 283 284This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 285applicable to the auth and account groups. 286 287=item ignore_root 288 289[1.1] Do not do anything if the username is C<root>. The authentication 290and password calls will silently fail (allowing that status to be ignored 291via a control of C<optional> or C<sufficient>), and the account and 292session calls (including pam_setcred) will return PAM_IGNORE, telling the 293PAM library to proceed as if they weren't mentioned in the PAM 294configuration. This option is supported and will remain, but normally you 295want to use I<minimum_uid> instead. 296 297This option can be set in C<[appdefaults]> in F<krb5.conf>. 298 299=item minimum_uid=<uid> 300 301[2.0] Do not do anything if the authenticated account name corresponds to 302a local account and that local account has a UID lower than <uid>. If 303both of those conditions are true, the authentication and password calls 304will silently fail (allowing that status to be ignored via a control of 305C<optional> or C<sufficient>), and the account and session calls 306(including pam_setcred) will return PAM_IGNORE, telling the PAM library to 307proceed as if they weren't mentioned in the PAM configuration. 308 309Using this option is highly recommended if you don't need to use Kerberos 310to authenticate password logins to the root account (which isn't 311recommended since Kerberos requires a network connection). It provides 312some defense in depth against user principals that happen to match a 313system account incorrectly authenticating as that system account. 314 315This option can be set in C<[appdefaults]> in F<krb5.conf>. 316 317=item only_alt_auth 318 319[3.12] This option is used with I<alt_auth_map> and forces the use of the 320mapped principal for authentication. It disables fallback to normal 321authentication in all cases and overrides I<search_k5login> and 322I<force_alt_auth>. If I<alt_auth_map> is not set, it has no effect and 323the standard authentication behavior is used. 324 325This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 326applicable to the auth group. 327 328=item search_k5login 329 330[2.0] Normally, the Kerberos implementation of pam_authenticate attempts 331to obtain tickets for the authenticating username in the local realm. If 332this option is set and the local user has a F<.k5login> file in their home 333directory, the module will instead open and read that F<.k5login> file, 334attempting to use the supplied password to authenticate as each principal 335listed there in turn. If any of those authentications succeed, the user 336will be successfully authenticated; otherwise, authentication will fail. 337This option is useful for allowing password authentication (via console or 338B<sshd> without GSS-API support) to shared accounts. If there is no 339F<.k5login> file, the behavior is the same as normal. Using this option 340requires that the user's F<.k5login> file be readable at the time of 341authentication. 342 343This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 344applicable to the auth group. 345 346=back 347 348=head2 Kerberos Behavior 349 350=over 4 351 352=item anon_fast 353 354[4.6] Attempt to use Flexible Authentication Secure Tunneling (FAST) by 355first authenticating as the anonymous user (WELLKNOWN/ANONYMOUS) and using 356its credentials as the FAST armor. This requires anonymous PKINIT be 357enabled for the local realm, that PKINIT be configured on the local 358system, and that the Kerberos library support FAST and anonymous PKINIT. 359 360FAST is a mechanism to protect Kerberos against password guessing attacks 361and provide other security improvements. To work, FAST requires that a 362ticket be obtained with a strong key to protect exchanges with potentially 363weaker user passwords. This option uses anonymous authentication to 364obtain that key and then uses it to protect the subsequent authentication. 365 366If anonymous PKINIT is not available or fails, FAST will not be used and 367the authentication will proceed as normal. 368 369To instead use an existing ticket cache for the FAST credentials, use 370I<fast_ccache> instead of this option. If both I<fast_ccache> and 371I<anon_fast> are set, the ticket cache named by I<fast_ccache> will be 372tried first, and the Kerberos PAM module will fall back on attempting 373anonymous PKINIT if that cache could not be used. 374 375This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 376applicable to the auth and password groups. 377 378The operation is the same as if using the I<fast_ccache> option, but the 379cache is created and destroyed automatically. If both I<fast_ccache> and 380I<anon_fast> options are used, the I<fast_ccache> takes precedent and no 381anonymous authentication is done. 382 383=item fast_ccache=<ccache_name> 384 385[4.3] The same as I<anon_fast>, but use an existing Kerberos ticket cache 386rather than anonymous PKINIT. This allows use of FAST with a realm that 387doesn't support PKINIT or doesn't support anonymous authentication. 388 389<ccache_name> should be a credential cache containing a ticket obtained 390using a strong key, such as the randomized key for the host principal of 391the local system. If <ccache_name> names a ticket cache that is readable 392by the authenticating process and has tickets then FAST will be attempted. 393The easiest way to use this option is to use a program like B<k5start> to 394maintain a ticket cache using the host's keytab. This ticket cache should 395normally only be readable by root, so this option will not be able to 396protect authentications done as non-root users (such as screensavers). 397 398If no credentials are present in the ticket cache, or if the ticket cache 399does not exist or is not readable, FAST will not used and authentication 400will proceed as normal. However, if the credentials in that ticket cache 401are expired, authentication will fail if the KDC supports FAST. 402 403To use anonymous PKINIT to protect the FAST exchange, use the I<anon_fast> 404option instead. I<anon_fast> is easier to configure, since no existing 405ticket cache is required, but requires PKINIT be available and configured 406and that the local realm support anonymous authentication. If both 407I<fast_ccache> and I<anon_fast> are set, the ticket cache named by 408I<fast_ccache> will be tried first, and the Kerberos PAM module will fall 409back on attempting anonymous PKINIT if that cache could not be used. 410 411This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 412applicable to the auth and password groups. 413 414=item forwardable 415 416[1.0] Obtain forwardable tickets. If set (to either true or false, 417although it can only be set to false in F<krb5.conf>), this overrides the 418Kerberos library default set in the [libdefaults] section of F<krb5.conf>. 419 420This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 421applicable to the auth group. 422 423=item keytab=<path> 424 425[3.0] Specifies the keytab to use when validating the user's credentials. 426The default is the default system keytab (normally F</etc/krb5.keytab>), 427which is usually only readable by root. Applications not running as root 428that use this PAM module for authentication may wish to point it to 429another keytab the application can read. The first principal found in the 430keytab will be used as the principal for credential verification. 431 432This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 433applicable to the auth group. 434 435=item realm=<realm> 436 437[2.2] Set the default Kerberos realm and obtain credentials in that realm, 438rather than in the normal default realm for this system. If this option 439is used, it should be set for all groups being used for consistent 440results. This setting will affect authorization decisions since it 441changes the default realm. This setting will also change the service 442principal used to verify the obtained credentials to be in the specified 443realm. 444 445If you only want to set the realm assumed for user principals without 446changing the realm for authorization decisions or the service principal 447used to verify credentials, see the I<user_realm> option. 448 449=item renew_lifetime=<lifetime> 450 451[2.0] Obtain renewable tickets with a maximum renewable lifetime of 452<lifetime>. <lifetime> should be a Kerberos lifetime string such as 453C<2d4h10m> or a time in minutes. If set, this overrides the Kerberos 454library default set in the [libdefaults] section of F<krb5.conf>. 455 456This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 457applicable to the auth group. 458 459=item ticket_lifetime=<lifetime> 460 461[3.0] Obtain tickets with a maximum lifetime of <lifetime>. <lifetime> 462should be a Kerberos lifetime string such as C<2d4h10m> or a time in 463minutes. If set, this overrides the Kerberos library default set in the 464[libdefaults] section of F<krb5.conf>. 465 466This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 467applicable to the auth group. 468 469=item user_realm 470 471[4.6] Obtain credentials in the specified realm rather than in the default 472realm for this system. If this option is used, it should be set for all 473groups being used for consistent results (although the account group 474currently doesn't care about realm). This will not change authorization 475decisions. If the obtained credentials are supposed to allow access to a 476shell account, the user will need an appropriate F<.k5login> file entry or 477the system will have to have a custom aname_to_localname mapping. 478 479=back 480 481=head2 PAM Behavior 482 483=over 4 484 485=item clear_on_fail 486 487[3.9] When changing passwords, PAM first does a preliminary check through 488the complete password stack, and then calls each module again to do the 489password change. After that preliminary check, the order of module 490invocation is fixed. This means that even if the Kerberos password change 491fails (or if one of the other password changes in the stack fails), other 492password PAM modules in the stack will still be called even if the failing 493module is marked required or requisite. When using multiple password PAM 494modules to synchronize passwords between multiple systems when they 495change, this behavior can cause unwanted differences between the 496environments. 497 498Setting this option provides a way to work around this behavior. If this 499option is set and a Kerberos password change is attempted and fails (due 500to network errors or password strength checking on the KDC, for example), 501this module will clear the stored password in the PAM stack. This will 502force any subsequent modules that have I<use_authtok> set to fail so that 503those environments won't get out of sync with the password in Kerberos. 504The Kerberos PAM module will not meddle with the stored password if it 505skips the user due to configuration such as minimum_uid. 506 507Unfortunately, setting this option interferes with other desirable PAM 508configurations, such as attempting to change the password in Kerberos 509first and falling back on the local Unix password database if that fails. 510It therefore isn't the default. Turn it on (and list pam_krb5 first after 511pam_cracklib if used) when synchronizing passwords between multiple 512environments. 513 514This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 515applicable to the password group. 516 517=item debug 518 519[1.0] Log more verbose trace and debugging information to syslog at 520LOG_DEBUG priority, including entry and exit from each of the external PAM 521interfaces (except pam_close_session). 522 523This option can be set in C<[appdefaults]> in F<krb5.conf>. 524 525=item defer_pwchange 526 527[3.11] By default, pam-krb5 lets the Kerberos library handle prompting for 528a password change if an account's password is expired during the auth 529group. If this fails, pam_authenticate() returns an error. 530 531According to the PAM standard, this is not the correct way to handle 532expired passwords. Instead, pam_authenticate() should return success 533without attempting a password change, and then pam_acct_mgmt() should 534return PAM_NEW_AUTHTOK_REQD, at which point the calling application is 535responsible for either rejecting the authentication or calling 536pam_chauthtok(). However, following the standard requires that all 537applications call pam_acct_mgmt() and check its return status; otherwise, 538expired accounts may be able to successfully authenticate. Many 539applications do not do this. 540 541If this option is set, pam-krb5 uses the fully correct PAM mechanism for 542handling expired accounts instead of failing in pam_authenticate(). Due 543to the security risk of widespread broken applications, be very careful 544about enabling this option. It should normally only be turned on to solve 545a specific problem (such as using Solaris Kerberos libraries that don't 546support prompting for password changes during authentication), and then 547only for specific applications known to call pam_acct_mgmt() and check its 548return status properly. 549 550This option is only supported when pam-krb5 is built with MIT Kerberos. 551If built against Heimdal, this option does nothing and normal expired 552password change handling still happens. (Heimdal is missing the required 553API to implement this option, at least as of version 1.6.) 554 555This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 556applicable to the auth group. 557 558=item fail_pwchange 559 560[4.2] By default, pam-krb5 lets the Kerberos library handle prompting for 561a password change if an account's password is expired during the auth 562group. If this option is set, expired passwords are instead treated as an 563authentication failure identical to an incorrect password. Also see 564I<defer_pwchange> and I<force_pwchange>. 565 566This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 567applicable to the auth group. 568 569=item force_pwchange 570 571[3.11] If this option is set and authentication fails with a Kerberos 572error indicating the user's password is expired, attempt to immediately 573change their password during the authenticate step. Under normal 574circumstances, this is unnecessary. Most Kerberos libraries will do this 575for you, and setting this option will prompt the user twice to change 576their password if the first attempt (done by the Kerberos library) fails. 577However, some system Kerberos libraries (such as Solaris's) have password 578change prompting disabled in the Kerberos library; on those systems, you 579can set this option to simulate the normal library behavior. 580 581This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 582applicable to the auth group. 583 584=item no_update_user 585 586[4.7] Normally, if pam-krb5 is able to canonicalize the principal to a 587local name using krb5_aname_to_localname() or similar calls, it changes 588the PAM_USER variable for this PAM session to the canonicalized local 589name. Setting this option disables this behavior and leaves PAM_USER set 590to the initial authentication identity. 591 592This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 593applicable to the auth group. 594 595=item silent 596 597[1.0] Don't show messages and errors from Kerberos, such as warnings of 598expiring passwords, to the user via the prompter. This is equivalent to 599the behavior when the application passes in PAM_SILENT, but can be set in 600the PAM configuration. 601 602This option is only applicable to the auth and password groups. 603 604=item trace=<log-file> 605 606[4.6] Enables Kerberos library trace logging to the specified log file if 607it is supported by the Kerberos library. This is intended for temporary 608debugging. The specified file will be appended to without further 609security checks, so do not specify a file in a publicly writable directory 610like F</tmp>. 611 612=back 613 614=head2 PKINIT 615 616=over 4 617 618=item pkinit_anchors=<anchors> 619 620[3.0] When doing PKINIT authentication, use <anchors> as the client trust 621anchors. This is normally a reference to a file containing the trusted 622certificate authorities. This option is only used if I<try_pkinit> or 623I<use_pkinit> are set. 624 625This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 626applicable to the auth and password groups. 627 628=item pkinit_prompt 629 630[3.0] Before attempting PKINIT authentication, prompt the user to insert a 631smart card. You may want to set this option for programs such as 632B<gnome-screensaver> that call PAM as soon as the mouse is touched and 633don't give the user an opportunity to enter the smart card first. Any 634information entered at the first prompt is ignored. If I<try_pkinit> is 635set, a user who wishes to use a password instead can just press Enter and 636then enter their password as normal. This option is only used if 637I<try_pkinit> or I<use_pkinit> are set. 638 639This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 640applicable to the auth and password groups. 641 642=item pkinit_user=<userid> 643 644[3.0] When doing PKINIT authentication, use <userid> as the user ID. The 645value of this string is highly dependent on the type of PKINIT 646implementation you're using, but will generally be something like: 647 648 PKCS11:/usr/lib/pkcs11/lib/soft-pkcs11.so 649 650to specify the module to use with a smart card. It may also point to a 651user certificate or to other types of user IDs. See the Kerberos library 652documentation for more details. This option is only used if I<try_pkinit> 653or I<use_pkinit> are set. 654 655This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 656applicable to the auth and password groups. 657 658=item preauth_opt=<option> 659 660[3.3] Sets a preauth option (currently only applicable when built with MIT 661Kerberos). <option> is either a key/value pair with the key separated 662from the value by C<=> or a boolean option (in which case it's turned on). 663In F<krb5.conf>, multiple options should be separated by whitespace. In 664the PAM configuration, this option can be given multiple times to set 665multiple options. In either case, <option> may not contain whitespace. 666 667The primary use of this option, at least in the near future, will be to 668set options for the MIT Kerberos PKINIT support. For the full list of 669possible options, see the PKINIT plugin documentation. At the time of 670this writing, C<X509_user_identity> is equivalent to I<pkinit_user> and 671C<X509_anchors> is equivalent to I<pkinit_anchors>. C<flag_DSA_PROTOCOL> 672can only be set via this option. 673 674Any settings made with this option are applied after the I<pkinit_anchors> 675and I<pkinit_user> options, so if an equivalent setting is made via 676I<preauth_opt>, it will probably override the other setting. 677 678This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 679applicable to the auth and password groups. Note that there is no way to 680remove a setting made in F<krb5.conf> using the PAM configuration, but 681options set in the PAM configuration are applied after options set in 682F<krb5.conf> and therefore may override earlier settings. 683 684=item try_pkinit 685 686[3.0] Attempt PKINIT authentication before trying a regular password. You 687will probably also need to set the I<pkinit_user> configuration option. 688If PKINIT fails, the PAM module will fall back on regular password 689authentication. This option is currently only supported if pam-krb5 was 690built against Heimdal 0.8rc1 or later or MIT Kerberos 1.6.3 or later. 691 692If this option is set and pam-krb5 is built against MIT Kerberos, and 693PKINIT fails and the module falls back to password authentication, the 694user's password will not be stored in the PAM stack for subsequent 695modules. This is a bug in the interaction between the module and MIT 696Kerberos that requires some reworking of the PKINIT authentication method 697to fix. 698 699This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 700applicable to the auth and password groups. 701 702=item use_pkinit 703 704[3.0, 4.9 for MIT Kerberos] Require PKINIT authentication. You will 705probably also need to set the I<pkinit_user> configuration option. If 706PKINIT fails, authentication will fail. This option is only supported if 707pam-krb5 was built against Heimdal 0.8rc1 or later or MIT Kerberos 1.12 or 708later. 709 710Be aware that, with MIT Kerberos, this option is implemented by using a 711responder without a prompter, and thus any informational messages from the 712Kerberos libraries or KDC during authentication will not be displayed. 713 714This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 715applicable to the auth and password groups. 716 717=back 718 719=head2 Prompting 720 721=over 4 722 723=item banner=<banner> 724 725[3.0] By default, the prompts when a user changes their password are: 726 727 Current Kerberos password: 728 Enter new Kerberos password: 729 Retype new Kerberos password: 730 731The string "Kerberos" is inserted so that users aren't confused about 732which password they're changing. Setting this option replaces the word 733"Kerberos" with whatever this option is set to. Setting this option to 734the empty string removes the word before "password:" entirely. 735 736If set in the PAM configuration, <banner> may not contain whitespace. If 737you want a value containing whitespace, set it in F<krb5.conf>. 738 739This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 740applicable to the password group. 741 742=item expose_account 743 744[3.0] By default, the Kerberos PAM module password prompt is simply 745"Password:". This avoids leaking any information about the system realm 746or account to principal conversions. If this option is set, the string 747"for <principal>" is added before the colon, where <principal> is the 748user's principal. This string is also added before the colon on prompts 749when changing the user's password. 750 751Enabling this option with ChallengeResponseAuthentication enabled in 752OpenSSH may cause problems for some ssh clients that only recognize 753"Password:" as a prompt. This option is automatically disabled if 754I<search_k5login> is enabled since the principal displayed would be 755inaccurate. 756 757This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 758applicable to the auth and password groups. 759 760=item force_first_pass 761 762[4.0] Use the password obtained by a previous authentication or password 763module to authenticate the user without prompting the user again. If no 764previous module obtained the user's password, fail without prompting the 765user. Also see I<try_first_pass> and I<use_first_pass> for weaker 766versions of this option. 767 768This option is only applicable to the auth and password groups. For the 769password group, it applies only to the old password. See I<use_authtok> 770for a similar setting for the new password. 771 772=item no_prompt 773 774[4.6] Never prompt for the current password. Instead, pass in a NULL 775password to the Kerberos library and let the Kerberos library do the 776prompting. This may be needed if, for example, the Kerberos library is 777configured to use other authentication mechanisms than passwords and needs 778full control over the prompting process. 779 780The major disadvantage of this option is that it means the PAM module will 781never see the user's password and therefore cannot save it in the PAM 782module data for any subsequent modules. In other words, this option 783cannot be used if another module is in the stack behind the Kerberos PAM 784module and wants to use I<use_first_pass>. The Kerberos library also 785usually includes the principal in the prompt, and therefore this option 786implies behavior similar to I<expose_account>. Similar to 787I<expose_account>, this can cause problems with OpenSSH if 788ChallengeResponseAuthentication is enabled, since clients may not 789recognize password prompts other than "Password:". 790 791Using this option with I<search_k5login> would result in a password prompt 792for every principal listed in the user's F<.k5login> file. This is 793probably not desired behavior, although it's not prohibited by the module. 794 795This option is only applicable to the auth and password groups. For the 796password group, it applies only to the authentication process; the user 797will still be prompted for a new password. 798 799=item prompt_principal 800 801[3.6] Before prompting for the user's password (or using the previously 802entered password, if I<try_first_pass>, I<use_first_pass>, or 803I<force_first_pass> are set), prompt the user for the Kerberos principal 804to use for authentication. This allows the user to authenticate with a 805different principal than the one corresponding to the local username, 806provided that either a F<.k5login> file or local Kerberos principal to 807account mapping authorize that principal to access the local account. 808 809Be cautious when using this configuration option and don't use it with 810OpenSSH PasswordAuthentication, only ChallengeResponseAuthentication. 811Some PAM-enabled applications expect PAM modules to only prompt for 812passwords and may even blindly give the password to the first prompt, no 813matter what it is. Such applications, in combination with this option, 814may expose the user's password in log messages and Kerberos requests. 815 816=item try_first_pass 817 818[1.0] If the authentication module isn't the first on the stack, and a 819previous module obtained the user's password, use that password to 820authenticate the user without prompting them again. If that 821authentication fails, fall back on prompting the user for their password. 822This option has no effect if the authentication module is first in the 823stack or if no previous module obtained the user's password. Also see 824I<use_first_pass> and I<force_first_pass> for stronger versions of this 825option. 826 827This option is only applicable to the auth and password groups. For the 828password group, it applies only to the old password. 829 830=item use_authtok 831 832[4.0] Use the new password obtained by a previous password module when 833changing passwords rather than prompting for the new password. If the new 834password isn't available, fail. This can be used to require passwords be 835checked by another, prior module, such as B<pam_cracklib>. 836 837This option is only applicable to the password group. 838 839=item use_first_pass 840 841[1.0] Use the password obtained by a previous authentication module to 842authenticate the user without prompting the user again. If no previous 843module obtained the user's password for either an authentication or 844password change, fall back on prompting the user. If a previous module 845did obtain the user's password but authentication with that password 846fails, fail without further prompting the user. Also see 847I<try_first_pass> and I<force_first_pass> for other versions of this 848option. 849 850This option is only applicable to the auth and password groups. For the 851password group, it applies only to the old password. See I<use_authtok> 852for a similar setting for the new password. 853 854=back 855 856=head2 Ticket Caches 857 858=over 4 859 860=item ccache=<pattern> 861 862[2.0] Use <pattern> as the pattern for creating credential cache names. 863<pattern> must be in the form <type>:<residual> where <type> and the 864following colon are optional if a file cache should be used. The special 865token C<%u>, anywhere in <pattern>, is replaced with the user's numeric 866UID. The special token C<%p>, anywhere in <pattern>, is replaced with the 867current process ID. 868 869If <pattern> ends in the literal string C<XXXXXX> (six X's), that string 870will be replaced by randomly generated characters and the ticket cache 871will be created using mkstemp(3). This is strongly recommended if 872<pattern> points to a world-writable directory. 873 874This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 875applicable to the auth and session groups. 876 877=item ccache_dir=<directory> 878 879[1.2] Store both the temporary ticket cache used during authentication and 880user ticket caches in <directory> instead of in F</tmp>. The algorithm 881for generating the ticket cache name is otherwise unchanged. <directory> 882may be prefixed with C<FILE:> to make the cache type unambiguous (and this 883may be required on systems that use a cache type other than file as the 884default). 885 886Be aware that pam_krb5 creates and stores a temporary ticket cache file 887owned by root during the login process. If you set I<ccache> above to 888avoid using the system F</tmp> directory for user ticket caches, you may 889also want to set I<ccache_dir> to move those temporary caches to some 890other location. This will allow pam_krb5 to continue working even if the 891system F</tmp> directory is full. 892 893This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 894applicable to the auth and session groups. 895 896=item no_ccache 897 898[1.0] Do not create a ticket cache after authentication. This option 899shouldn't be set in general, but is useful as part of the PAM 900configuration for a particular service that uses PAM for authentication 901but isn't creating user sessions and doesn't want the overhead of ever 902writing the user credentials to disk. When using this option, the 903application should only call pam_authenticate(); other functions like 904pam_setcred(), pam_start_session(), and pam_acct_mgmt() don't make sense 905with this option. Don't use this option if the application needs PAM 906account and session management calls. 907 908This option is only applicable to the auth group. 909 910=item retain_after_close 911 912[2.3] Normally, the user's ticket cache is destroyed when either pam_end() 913or pam_close_session() is called by the authenticating application so that 914ticket caches aren't left behind after the user logs out. In some cases, 915however, this isn't desirable. (On Solaris 8, for instance, the default 916behavior means login will destroy the ticket cache before running the 917user's shell.) If this option is set, the PAM module will never destroy 918the user's ticket cache. If you set this, you may want to call 919B<kdestroy> in the shell's logout configuration or run a temporary file 920removal program to avoid accumulating hundreds of ticket caches in 921F</tmp>. 922 923This option can be set in C<[appdefaults]> in F<krb5.conf> and is only 924applicable to the auth and session groups. 925 926=back 927 928=head1 ENVIRONMENT 929 930=over 4 931 932=item KRB5CCNAME 933 934Set by pam_setcred() with the PAM_ESTABLISH_CRED option, and therefore 935also by pam_open_session(), to point to the new credential cache for the 936user. See the I<ccache> and I<ccache_dir> options. By default, the cache 937name will be prefixed with C<FILE:> to make the cache type unambiguous. 938 939=item PAM_KRB5CCNAME 940 941Set by pam_authenticate() to point to the temporary ticket cache used for 942authentication (unless the I<no_ccache> option was given). pam_setcred() 943then uses that environment variable to locate the temporary cache even if 944it was not called in the same PAM session as pam_authenticate() (a problem 945with B<sshd> running in some modes). This environment variable is only 946used internal to the PAM module. 947 948=back 949 950=head1 FILES 951 952=over 4 953 954=item F</tmp/krb5cc_UID_RANDOM> 955 956The default credential cache name. UID is the decimal UID of the local 957user and RANDOM is a random six-character string. The pattern may be 958changed with the I<ccache> option and the directory with the I<ccache_dir> 959option. 960 961=item F</tmp/krb5cc_pam_RANDOM> 962 963The credential cache name used for the temporary credential cache created 964by pam_authenticate(). This cache is removed again when the PAM session 965is ended or when pam_setcred() is called and will normally not be 966user-visible. RANDOM is a random six-character string. 967 968=item F<~/.k5login> 969 970File containing Kerberos principals that are allowed access to that 971account. 972 973=back 974 975=head1 BUGS 976 977If I<try_pkinit> is set and pam-krb5 is built with MIT Kerberos, the 978user's password is not saved in the PAM data if PKINIT fails and the 979module falls back to password authentication. 980 981=head1 CAVEATS 982 983Be sure to list this module in the session group as well as the auth group 984when using it for interactive logins. Otherwise, some applications (such 985as OpenSSH) will not set up the user's ticket cache correctly. 986 987The Kerberos library, via pam-krb5, will prompt the user to change their 988password if their password is expired, but when using OpenSSH, this will 989only work when ChallengeResponseAuthentication is enabled. Unless this 990option is enabled, OpenSSH doesn't pass PAM messages to the user and can 991only respond to a simple password prompt. 992 993If you are using MIT Kerberos, be aware that users whose passwords are 994expired will not be prompted to change their password unless the KDC 995configuration for your realm in [realms] in krb5.conf contains a 996master_kdc setting or, if using DNS SRV records, you have a DNS entry for 997_kerberos-master as well as _kerberos. 998 999pam_authenticate() returns failure when called for an ignored account, 1000requiring the system administrator to use C<optional> or C<sufficient> to 1001ignore the module and move on to the next module. It's arguably more 1002correct to return PAM_IGNORE, which causes the module to be ignored as if 1003it weren't in the configuration, but this increases the risk of 1004inadvertent security holes when listing pam-krb5 as the only 1005authentication module. 1006 1007This module treats the empty password as an authentication failure 1008rather than attempting to use that password to avoid unwanted prompting 1009behavior in the Kerberos libraries. If you have a Kerberos principal that 1010intentionally has an empty password, it won't work with this module. 1011 1012This module will not refresh an existing ticket cache if called with an 1013effective UID or GID different than the real UID or GID, since refreshing 1014an existing ticket cache requires trusting the KRB5CCNAME environment 1015variable and the environment should not be trusted in a setuid context. 1016 1017Old versions of OpenSSH are known to call pam_authenticate followed by 1018pam_setcred(PAM_REINITIALIZE_CRED) without first calling pam_open_session, 1019thereby requesting that an existing ticket cache be renewed (similar to 1020what a screensaver would want) rather than requesting a new ticket cache 1021be created. Since this behavior is indistinguishable at the PAM level 1022from a screensaver, pam-krb5 when used with these old versions of OpenSSH 1023will refresh the ticket cache of the OpenSSH daemon rather than setting up 1024a new ticket cache for the user. The resulting ticket cache will have the 1025correct permissions, but will not be named correctly or referenced in the 1026user's environment and will be overwritten by the next user login. The 1027best solution to this problem is to upgrade OpenSSH. I'm not sure exactly 1028when this problem was fixed, but at the very least OpenSSH 4.3 and later 1029do not exhibit it. 1030 1031=head1 AUTHOR 1032 1033pam-krb5 was originally written by Frank Cusack. Andres Salomon made 1034extensive modifications, and then Russ Allbery <eagle@eyrie.org> adopted 1035it and made even more extensive modifications. Russ Allbery currently 1036maintains the module. 1037 1038=head1 COPYRIGHT AND LICENSE 1039 1040Copyright 2005-2010, 2014, 2020 Russ Allbery <eagle@eyrie.org> 1041 1042Copyright 2008-2014 The Board of Trustees of the Leland Stanford Junior 1043University 1044 1045Copying and distribution of this file, with or without modification, are 1046permitted in any medium without royalty provided the copyright notice and 1047this notice are preserved. This file is offered as-is, without any 1048warranty. 1049 1050SPDX-License-Identifier: FSFAP 1051 1052=head1 SEE ALSO 1053 1054kadmin(8), kdestroy(1), krb5.conf(5), pam(7), passwd(1), syslog(3) 1055 1056The current version of this module is available from its web page at 1057L<https://www.eyrie.org/~eagle/software/pam-krb5/>. 1058 1059=cut 1060