1*bf6873c5SCy Schubert pam-krb5 4.11 2*bf6873c5SCy Schubert (PAM module for Kerberos authentication) 3*bf6873c5SCy Schubert Maintained by Russ Allbery <eagle@eyrie.org> 4*bf6873c5SCy Schubert 5*bf6873c5SCy Schubert Copyright 2005-2010, 2014-2015, 2017, 2020-2021 Russ Allbery 6*bf6873c5SCy Schubert <eagle@eyrie.org>. Copyright 2009-2011 The Board of Trustees of the 7*bf6873c5SCy Schubert Leland Stanford Junior University. Copyright 2005 Andres Salomon 8*bf6873c5SCy Schubert <dilinger@debian.org>. Copyright 1999-2000 Frank Cusack 9*bf6873c5SCy Schubert <fcusack@fcusack.com>. This software is distributed under a BSD-style 10*bf6873c5SCy Schubert license. Please see the section LICENSE below for more information. 11*bf6873c5SCy Schubert 12*bf6873c5SCy SchubertBLURB 13*bf6873c5SCy Schubert 14*bf6873c5SCy Schubert pam-krb5 is a Kerberos PAM module for either MIT Kerberos or Heimdal. 15*bf6873c5SCy Schubert It supports ticket refreshing by screen savers, configurable 16*bf6873c5SCy Schubert authorization handling, authentication of non-local accounts for network 17*bf6873c5SCy Schubert services, password changing, and password expiration, as well as all the 18*bf6873c5SCy Schubert standard expected PAM features. It works correctly with OpenSSH, even 19*bf6873c5SCy Schubert with ChallengeResponseAuthentication and PrivilegeSeparation enabled, 20*bf6873c5SCy Schubert and supports extensive configuration either by PAM options or in 21*bf6873c5SCy Schubert krb5.conf or both. PKINIT is supported with recent versions of both MIT 22*bf6873c5SCy Schubert Kerberos and Heimdal and FAST is supported with recent MIT Kerberos. 23*bf6873c5SCy Schubert 24*bf6873c5SCy SchubertDESCRIPTION 25*bf6873c5SCy Schubert 26*bf6873c5SCy Schubert pam-krb5 provides a Kerberos PAM module that supports authentication, 27*bf6873c5SCy Schubert user ticket cache handling, simple authorization (via .k5login or 28*bf6873c5SCy Schubert checking Kerberos principals against local usernames), and password 29*bf6873c5SCy Schubert changing. It can be configured through either options in the PAM 30*bf6873c5SCy Schubert configuration itself or through entries in the system krb5.conf file, 31*bf6873c5SCy Schubert and it tries to work around PAM implementation flaws in commonly-used 32*bf6873c5SCy Schubert PAM-enabled applications such as OpenSSH and xdm. It supports both 33*bf6873c5SCy Schubert PKINIT and FAST to the extent that the underlying Kerberos libraries 34*bf6873c5SCy Schubert support these features. 35*bf6873c5SCy Schubert 36*bf6873c5SCy Schubert This is not the Kerberos PAM module maintained on Sourceforge and used 37*bf6873c5SCy Schubert on Red Hat systems. It is an independent implementation that, if it 38*bf6873c5SCy Schubert ever shared any common code, diverged long ago. It supports some 39*bf6873c5SCy Schubert features that the Sourceforge module does not (particularly around 40*bf6873c5SCy Schubert authorization), and does not support some options (particularly ones not 41*bf6873c5SCy Schubert directly related to Kerberos) that it does. This module will never 42*bf6873c5SCy Schubert support Kerberos v4 or AFS. For an AFS session module that works with 43*bf6873c5SCy Schubert this module (or any other Kerberos PAM module), see pam-afs-session [1]. 44*bf6873c5SCy Schubert 45*bf6873c5SCy Schubert [1] https://www.eyrie.org/~eagle/software/pam-afs-session/ 46*bf6873c5SCy Schubert 47*bf6873c5SCy Schubert If there are other options besides AFS and Kerberos v4 support from the 48*bf6873c5SCy Schubert Sourceforge PAM module that you're missing in this module, please let me 49*bf6873c5SCy Schubert know. 50*bf6873c5SCy Schubert 51*bf6873c5SCy SchubertREQUIREMENTS 52*bf6873c5SCy Schubert 53*bf6873c5SCy Schubert Either MIT Kerberos (or Kerberos implementations based on it) or Heimdal 54*bf6873c5SCy Schubert are supported. MIT Keberos 1.3 or later may be required; this module 55*bf6873c5SCy Schubert has not been tested with earlier versions. 56*bf6873c5SCy Schubert 57*bf6873c5SCy Schubert For PKINIT support, Heimdal 0.8rc1 or later or MIT Kerberos 1.6.3 or 58*bf6873c5SCy Schubert later are required. Earlier MIT Kerberos 1.6 releases have a bug in 59*bf6873c5SCy Schubert their handling of PKINIT options. MIT Kerberos 1.12 or later is 60*bf6873c5SCy Schubert required to use the use_pkinit PAM option. 61*bf6873c5SCy Schubert 62*bf6873c5SCy Schubert For FAST (Flexible Authentication Secure Tunneling) support, MIT 63*bf6873c5SCy Schubert Kerberos 1.7 or higher is required. For anonymous FAST support, 64*bf6873c5SCy Schubert anonymous authentication (generally anonymous PKINIT) support is 65*bf6873c5SCy Schubert required in both the Kerberos libraries and in the local KDC. 66*bf6873c5SCy Schubert 67*bf6873c5SCy Schubert This module should work on Linux and build with gcc or clang. It may 68*bf6873c5SCy Schubert still work on Solaris and build with the Sun C compiler, but I have only 69*bf6873c5SCy Schubert tested it on Linux recently. There is beta-quality support for the AIX 70*bf6873c5SCy Schubert NAS Kerberos implementation that has not been tested in years. Other 71*bf6873c5SCy Schubert PAM implementations will probably require some porting, although 72*bf6873c5SCy Schubert untested build system support is present for FreeBSD, Mac OS X, and 73*bf6873c5SCy Schubert HP-UX. I personally can only test on Linux and rely on others to report 74*bf6873c5SCy Schubert problems on other operating systems. 75*bf6873c5SCy Schubert 76*bf6873c5SCy Schubert Old versions of OpenSSH are known to call pam_authenticate followed by 77*bf6873c5SCy Schubert pam_setcred(PAM_REINITIALIZE_CRED) without first calling 78*bf6873c5SCy Schubert pam_open_session, thereby requesting that an existing ticket cache be 79*bf6873c5SCy Schubert renewed (similar to what a screensaver would want) rather than 80*bf6873c5SCy Schubert requesting a new ticket cache be created. Since this behavior is 81*bf6873c5SCy Schubert indistinguishable at the PAM level from a screensaver, pam-krb5 when 82*bf6873c5SCy Schubert used with these old versions of OpenSSH will refresh the ticket cache of 83*bf6873c5SCy Schubert the OpenSSH daemon rather than setting up a new ticket cache for the 84*bf6873c5SCy Schubert user. The resulting ticket cache will have the correct permissions 85*bf6873c5SCy Schubert (this is not a security concern), but will not be named correctly or 86*bf6873c5SCy Schubert referenced in the user's environment and will be overwritten by the next 87*bf6873c5SCy Schubert user login. The best solution to this problem is to upgrade OpenSSH. 88*bf6873c5SCy Schubert I'm not sure exactly when this problem was fixed, but at the very least 89*bf6873c5SCy Schubert OpenSSH 4.3 and later do not exhibit it. 90*bf6873c5SCy Schubert 91*bf6873c5SCy Schubert To bootstrap from a Git checkout, or if you change the Automake files 92*bf6873c5SCy Schubert and need to regenerate Makefile.in, you will need Automake 1.11 or 93*bf6873c5SCy Schubert later. For bootstrap or if you change configure.ac or any of the m4 94*bf6873c5SCy Schubert files it includes and need to regenerate configure or config.h.in, you 95*bf6873c5SCy Schubert will need Autoconf 2.64 or later. Perl is also required to generate 96*bf6873c5SCy Schubert manual pages from a fresh Git checkout. 97*bf6873c5SCy Schubert 98*bf6873c5SCy SchubertBUILDING AND INSTALLATION 99*bf6873c5SCy Schubert 100*bf6873c5SCy Schubert You can build and install pam-krb5 with the standard commands: 101*bf6873c5SCy Schubert 102*bf6873c5SCy Schubert ./configure 103*bf6873c5SCy Schubert make 104*bf6873c5SCy Schubert make install 105*bf6873c5SCy Schubert 106*bf6873c5SCy Schubert If you are building from a Git clone, first run ./bootstrap in the 107*bf6873c5SCy Schubert source directory to generate the build files. make install will 108*bf6873c5SCy Schubert probably have to be done as root. Building outside of the source 109*bf6873c5SCy Schubert directory is also supported, if you wish, by creating an empty directory 110*bf6873c5SCy Schubert and then running configure with the correct relative path. 111*bf6873c5SCy Schubert 112*bf6873c5SCy Schubert The module will be installed in /usr/local/lib/security by default, but 113*bf6873c5SCy Schubert expect to have to override this using --libdir. The correct 114*bf6873c5SCy Schubert installation path for PAM modules varies considerably between systems. 115*bf6873c5SCy Schubert The module will always be installed in a subdirectory named security 116*bf6873c5SCy Schubert under the specified value of --libdir. On Red Hat Linux, for example, 117*bf6873c5SCy Schubert --libdir=/usr/lib64 is appropriate to install the module into the system 118*bf6873c5SCy Schubert PAM directory. On Debian's amd64 architecture, 119*bf6873c5SCy Schubert --libdir=/usr/lib/x86_64-linux-gnu would be correct. 120*bf6873c5SCy Schubert 121*bf6873c5SCy Schubert Normally, configure will use krb5-config to determine the flags to use 122*bf6873c5SCy Schubert to compile with your Kerberos libraries. To specify a particular 123*bf6873c5SCy Schubert krb5-config script to use, either set the PATH_KRB5_CONFIG environment 124*bf6873c5SCy Schubert variable or pass it to configure like: 125*bf6873c5SCy Schubert 126*bf6873c5SCy Schubert ./configure PATH_KRB5_CONFIG=/path/to/krb5-config 127*bf6873c5SCy Schubert 128*bf6873c5SCy Schubert If krb5-config isn't found, configure will look for the standard 129*bf6873c5SCy Schubert Kerberos libraries in locations already searched by your compiler. If 130*bf6873c5SCy Schubert the the krb5-config script first in your path is not the one 131*bf6873c5SCy Schubert corresponding to the Kerberos libraries you want to use, or if your 132*bf6873c5SCy Schubert Kerberos libraries and includes aren't in a location searched by default 133*bf6873c5SCy Schubert by your compiler, you need to specify a different Kerberos installation 134*bf6873c5SCy Schubert root via --with-krb5=PATH. For example: 135*bf6873c5SCy Schubert 136*bf6873c5SCy Schubert ./configure --with-krb5=/usr/pubsw 137*bf6873c5SCy Schubert 138*bf6873c5SCy Schubert You can also individually set the paths to the include directory and the 139*bf6873c5SCy Schubert library directory with --with-krb5-include and --with-krb5-lib. You may 140*bf6873c5SCy Schubert need to do this if Autoconf can't figure out whether to use lib, lib32, 141*bf6873c5SCy Schubert or lib64 on your platform. 142*bf6873c5SCy Schubert 143*bf6873c5SCy Schubert To not use krb5-config and force library probing even if there is a 144*bf6873c5SCy Schubert krb5-config script on your path, set PATH_KRB5_CONFIG to a nonexistent 145*bf6873c5SCy Schubert path: 146*bf6873c5SCy Schubert 147*bf6873c5SCy Schubert ./configure PATH_KRB5_CONFIG=/nonexistent 148*bf6873c5SCy Schubert 149*bf6873c5SCy Schubert krb5-config is not used and library probing is always done if either 150*bf6873c5SCy Schubert --with-krb5-include or --with-krb5-lib are given. 151*bf6873c5SCy Schubert 152*bf6873c5SCy Schubert Pass --enable-silent-rules to configure for a quieter build (similar to 153*bf6873c5SCy Schubert the Linux kernel). Use make warnings instead of make to build with full 154*bf6873c5SCy Schubert compiler warnings (requires either GCC or Clang and may require a 155*bf6873c5SCy Schubert relatively current version of the compiler). 156*bf6873c5SCy Schubert 157*bf6873c5SCy Schubert You can pass the --enable-reduced-depends flag to configure to try to 158*bf6873c5SCy Schubert minimize the shared library dependencies encoded in the binaries. This 159*bf6873c5SCy Schubert omits from the link line all the libraries included solely because other 160*bf6873c5SCy Schubert libraries depend on them and instead links the programs only against 161*bf6873c5SCy Schubert libraries whose APIs are called directly. This will only work with 162*bf6873c5SCy Schubert shared libraries and will only work on platforms where shared libraries 163*bf6873c5SCy Schubert properly encode their own dependencies (this includes most modern 164*bf6873c5SCy Schubert platforms such as all Linux). It is intended primarily for building 165*bf6873c5SCy Schubert packages for Linux distributions to avoid encoding unnecessary shared 166*bf6873c5SCy Schubert library dependencies that make shared library migrations more difficult. 167*bf6873c5SCy Schubert If none of the above made any sense to you, don't bother with this flag. 168*bf6873c5SCy Schubert 169*bf6873c5SCy SchubertTESTING 170*bf6873c5SCy Schubert 171*bf6873c5SCy Schubert pam-krb5 comes with a comprehensive test suite, but it requires some 172*bf6873c5SCy Schubert configuration in order to test anything other than low-level utility 173*bf6873c5SCy Schubert functions. For the full test suite, you will need to have a running KDC 174*bf6873c5SCy Schubert in which you can create two test accounts, one with admin access to the 175*bf6873c5SCy Schubert other. Using a test KDC environment, if you have one, is recommended. 176*bf6873c5SCy Schubert 177*bf6873c5SCy Schubert Follow the instructions in tests/config/README to configure the test 178*bf6873c5SCy Schubert suite. 179*bf6873c5SCy Schubert 180*bf6873c5SCy Schubert Now, you can run the test suite with: 181*bf6873c5SCy Schubert 182*bf6873c5SCy Schubert make check 183*bf6873c5SCy Schubert 184*bf6873c5SCy Schubert If a test fails, you can run a single test with verbose output via: 185*bf6873c5SCy Schubert 186*bf6873c5SCy Schubert tests/runtests -o <name-of-test> 187*bf6873c5SCy Schubert 188*bf6873c5SCy Schubert Do this instead of running the test program directly since it will 189*bf6873c5SCy Schubert ensure that necessary environment variables are set up. 190*bf6873c5SCy Schubert 191*bf6873c5SCy Schubert The default libkadm5clnt library on the system must match the 192*bf6873c5SCy Schubert implementation of your KDC for the module/expired test to work, since 193*bf6873c5SCy Schubert the two kadmin protocols are not compatible. If you use the MIT library 194*bf6873c5SCy Schubert against a Heimdal server, the test will be skipped; if you use the 195*bf6873c5SCy Schubert Heimdal library against an MIT server, the test suite may hang. 196*bf6873c5SCy Schubert 197*bf6873c5SCy Schubert Several module/expired tests are expected to fail with Heimdal 1.5 due 198*bf6873c5SCy Schubert to a bug in Heimdal with reauthenticating immediately after a 199*bf6873c5SCy Schubert library-mediated password change of an expired password. This is fixed 200*bf6873c5SCy Schubert in later releases of Heimdal. 201*bf6873c5SCy Schubert 202*bf6873c5SCy Schubert To run the full test suite, Perl 5.10 or later is required. The 203*bf6873c5SCy Schubert following additional Perl modules will be used if present: 204*bf6873c5SCy Schubert 205*bf6873c5SCy Schubert * Test::Pod 206*bf6873c5SCy Schubert * Test::Spelling 207*bf6873c5SCy Schubert 208*bf6873c5SCy Schubert All are available on CPAN. Those tests will be skipped if the modules 209*bf6873c5SCy Schubert are not available. 210*bf6873c5SCy Schubert 211*bf6873c5SCy Schubert To enable tests that don't detect functionality problems but are used to 212*bf6873c5SCy Schubert sanity-check the release, set the environment variable RELEASE_TESTING 213*bf6873c5SCy Schubert to a true value. To enable tests that may be sensitive to the local 214*bf6873c5SCy Schubert environment or that produce a lot of false positives without uncovering 215*bf6873c5SCy Schubert many problems, set the environment variable AUTHOR_TESTING to a true 216*bf6873c5SCy Schubert value. 217*bf6873c5SCy Schubert 218*bf6873c5SCy SchubertCONFIGURING 219*bf6873c5SCy Schubert 220*bf6873c5SCy Schubert Just installing the module does not enable it or change anything about 221*bf6873c5SCy Schubert your system authentication configuration. To use the module for all 222*bf6873c5SCy Schubert system authentication on Debian systems, put something like: 223*bf6873c5SCy Schubert 224*bf6873c5SCy Schubert auth sufficient pam_krb5.so minimum_uid=1000 225*bf6873c5SCy Schubert auth required pam_unix.so try_first_pass nullok_secure 226*bf6873c5SCy Schubert 227*bf6873c5SCy Schubert in /etc/pam.d/common-auth, something like: 228*bf6873c5SCy Schubert 229*bf6873c5SCy Schubert session optional pam_krb5.so minimum_uid=1000 230*bf6873c5SCy Schubert session required pam_unix.so 231*bf6873c5SCy Schubert 232*bf6873c5SCy Schubert in /etc/pam.d/common-session, and something like: 233*bf6873c5SCy Schubert 234*bf6873c5SCy Schubert account required pam_krb5.so minimum_uid=1000 235*bf6873c5SCy Schubert account required pam_unix.so 236*bf6873c5SCy Schubert 237*bf6873c5SCy Schubert in /etc/pam.d/common-account. The minimum_uid setting tells the PAM 238*bf6873c5SCy Schubert module to pass on any users with a UID lower than 1000, thereby 239*bf6873c5SCy Schubert bypassing Kerberos authentication for the root account and any system 240*bf6873c5SCy Schubert accounts. You normally want to do this since otherwise, if the network 241*bf6873c5SCy Schubert is down, the Kerberos authentication can time out and make it difficult 242*bf6873c5SCy Schubert to log in as root and fix matters. This also avoids problems with 243*bf6873c5SCy Schubert Kerberos principals that happen to match system accounts accidentally 244*bf6873c5SCy Schubert getting access to those accounts. 245*bf6873c5SCy Schubert 246*bf6873c5SCy Schubert Be sure to include the module in the session group as well as the auth 247*bf6873c5SCy Schubert group. Without the session entry, the user's ticket cache will not be 248*bf6873c5SCy Schubert created properly for ssh logins (among possibly others). 249*bf6873c5SCy Schubert 250*bf6873c5SCy Schubert If your users should normally all use Kerberos passwords exclusively, 251*bf6873c5SCy Schubert putting something like: 252*bf6873c5SCy Schubert 253*bf6873c5SCy Schubert password sufficient pam_krb5.so minimum_uid=1000 254*bf6873c5SCy Schubert password required pam_unix.so try_first_pass obscure md5 255*bf6873c5SCy Schubert 256*bf6873c5SCy Schubert in /etc/pam.d/common-password will change users' passwords in Kerberos 257*bf6873c5SCy Schubert by default and then only fall back on Unix if that doesn't work. (You 258*bf6873c5SCy Schubert can make this tighter by using the more complex new-style PAM 259*bf6873c5SCy Schubert configuration.) If you instead want to synchronize local and Kerberos 260*bf6873c5SCy Schubert passwords and change them both at the same time, you can do something 261*bf6873c5SCy Schubert like: 262*bf6873c5SCy Schubert 263*bf6873c5SCy Schubert password required pam_unix.so obscure sha512 264*bf6873c5SCy Schubert password required pam_krb5.so use_authtok minimum_uid=1000 265*bf6873c5SCy Schubert 266*bf6873c5SCy Schubert If you have multiple environments that you want to synchronize and you 267*bf6873c5SCy Schubert don't want password changes to continue if the Kerberos password change 268*bf6873c5SCy Schubert fails, use the clear_on_fail option. For example: 269*bf6873c5SCy Schubert 270*bf6873c5SCy Schubert password required pam_krb5.so clear_on_fail minimum_uid=1000 271*bf6873c5SCy Schubert password required pam_unix.so use_authtok obscure sha512 272*bf6873c5SCy Schubert password required pam_smbpass.so use_authtok 273*bf6873c5SCy Schubert 274*bf6873c5SCy Schubert In this case, if pam_krb5 cannot change the password (due to password 275*bf6873c5SCy Schubert strength rules on the KDC, for example), it will clear the stored 276*bf6873c5SCy Schubert password (because of the clear_on_fail option), and since pam_unix and 277*bf6873c5SCy Schubert pam_smbpass are both configured with use_authtok, they will both fail. 278*bf6873c5SCy Schubert clear_on_fail is not the default because it would interfere with the 279*bf6873c5SCy Schubert more common pattern of falling back to local passwords if the user 280*bf6873c5SCy Schubert doesn't exist in Kerberos. 281*bf6873c5SCy Schubert 282*bf6873c5SCy Schubert If you use a more complex configuration with the Linux PAM [] syntax for 283*bf6873c5SCy Schubert the session and account groups, note that pam_krb5 returns a status of 284*bf6873c5SCy Schubert ignore, not success, if the user didn't log on with Kerberos. You may 285*bf6873c5SCy Schubert need to handle that explicitly with ignore=ignore in your action list. 286*bf6873c5SCy Schubert 287*bf6873c5SCy Schubert There are many, many other possibilities. See the Linux PAM 288*bf6873c5SCy Schubert documentation for all the configuration options. 289*bf6873c5SCy Schubert 290*bf6873c5SCy Schubert On Red Hat systems, modify /etc/pam.d/system-auth instead, which 291*bf6873c5SCy Schubert contains all of the configuration for the different stacks. 292*bf6873c5SCy Schubert 293*bf6873c5SCy Schubert You can also use pam-krb5 only for specific services. In that case, 294*bf6873c5SCy Schubert modify the files in /etc/pam.d for that particular service to use 295*bf6873c5SCy Schubert pam_krb5.so for authentication. For services that are using passwords 296*bf6873c5SCy Schubert over TLS to authenticate users, you may want to use the ignore_k5login 297*bf6873c5SCy Schubert and no_ccache options to the authenticate module. .k5login 298*bf6873c5SCy Schubert authorization is only meaningful for local accounts and ticket caches 299*bf6873c5SCy Schubert are usually (although not always) only useful for interactive sessions. 300*bf6873c5SCy Schubert 301*bf6873c5SCy Schubert Configuring the module for Solaris is both simpler and less flexible, 302*bf6873c5SCy Schubert since Solaris (at least Solaris 8 and 9, which are the last versions of 303*bf6873c5SCy Schubert Solaris with which this module was extensively tested) use a single 304*bf6873c5SCy Schubert /etc/pam.conf file that contains configuration for all programs. For 305*bf6873c5SCy Schubert console login on Solaris, try something like: 306*bf6873c5SCy Schubert 307*bf6873c5SCy Schubert login auth sufficient /usr/local/lib/security/pam_krb5.so minimum_uid=100 308*bf6873c5SCy Schubert login auth required /usr/lib/security/pam_unix_auth.so.1 use_first_pass 309*bf6873c5SCy Schubert login account required /usr/local/lib/security/pam_krb5.so minimum_uid=100 310*bf6873c5SCy Schubert login account required /usr/lib/security/pam_unix_account.so.1 311*bf6873c5SCy Schubert login session required /usr/local/lib/security/pam_krb5.so retain_after_close minimum_uid=100 312*bf6873c5SCy Schubert login session required /usr/lib/security/pam_unix_session.so.1 313*bf6873c5SCy Schubert 314*bf6873c5SCy Schubert A similar configuration could be used for other services, such as ssh. 315*bf6873c5SCy Schubert See the pam.conf(5) man page for more information. When using this 316*bf6873c5SCy Schubert module with Solaris login (at least on Solaris 8 and 9), you will 317*bf6873c5SCy Schubert probably also need to add retain_after_close to the PAM configuration to 318*bf6873c5SCy Schubert avoid having the user's credentials deleted before they are logged in. 319*bf6873c5SCy Schubert 320*bf6873c5SCy Schubert The Solaris Kerberos library reportedly does not support prompting for a 321*bf6873c5SCy Schubert password change of an expired account during authentication. Supporting 322*bf6873c5SCy Schubert password change for expired accounts on Solaris with native Kerberos may 323*bf6873c5SCy Schubert therefore require setting the defer_pwchange or force_pwchange option 324*bf6873c5SCy Schubert for selected login applications. See the description and warnings about 325*bf6873c5SCy Schubert that option in the pam_krb5(5) man page. 326*bf6873c5SCy Schubert 327*bf6873c5SCy Schubert Some configuration options may be put in the krb5.conf file used by your 328*bf6873c5SCy Schubert Kerberos libraries (usually /etc/krb5.conf or /usr/local/etc/krb5.conf) 329*bf6873c5SCy Schubert instead or in addition to the PAM configuration. See the man page for 330*bf6873c5SCy Schubert more details. 331*bf6873c5SCy Schubert 332*bf6873c5SCy Schubert The Kerberos library, via pam-krb5, will prompt the user to change their 333*bf6873c5SCy Schubert password if their password is expired, but when using OpenSSH, this will 334*bf6873c5SCy Schubert only work when ChallengeResponseAuthentication is enabled. Unless this 335*bf6873c5SCy Schubert option is enabled, OpenSSH doesn't pass PAM messages to the user and can 336*bf6873c5SCy Schubert only respond to a simple password prompt. 337*bf6873c5SCy Schubert 338*bf6873c5SCy Schubert If you are using MIT Kerberos, be aware that users whose passwords are 339*bf6873c5SCy Schubert expired will not be prompted to change their password unless the KDC 340*bf6873c5SCy Schubert configuration for your realm in [realms] in krb5.conf contains a 341*bf6873c5SCy Schubert master_kdc setting or, if using DNS SRV records, you have a DNS entry 342*bf6873c5SCy Schubert for _kerberos-master as well as _kerberos. 343*bf6873c5SCy Schubert 344*bf6873c5SCy SchubertDEBUGGING 345*bf6873c5SCy Schubert 346*bf6873c5SCy Schubert The first step when debugging any problems with this module is to add 347*bf6873c5SCy Schubert debug to the PAM options for the module (either in the PAM configuration 348*bf6873c5SCy Schubert or in krb5.conf). This will significantly increase the logging from the 349*bf6873c5SCy Schubert module and should provide a trace of exactly what failed and any 350*bf6873c5SCy Schubert available error information. 351*bf6873c5SCy Schubert 352*bf6873c5SCy Schubert Many Kerberos authentication problems are due to configuration issues in 353*bf6873c5SCy Schubert krb5.conf. If pam-krb5 doesn't work, first check that kinit works on 354*bf6873c5SCy Schubert the same system. That will test your basic Kerberos configuration. If 355*bf6873c5SCy Schubert the system has a keytab file installed that's readable by the process 356*bf6873c5SCy Schubert doing authentication via PAM, make sure that the keytab is current and 357*bf6873c5SCy Schubert contains a key for host/<system> where <system> is the fully-qualified 358*bf6873c5SCy Schubert hostname. pam-krb5 prevents KDC spoofing by checking the user's 359*bf6873c5SCy Schubert credentials when possible, but this means that if a keytab is present it 360*bf6873c5SCy Schubert must be correct or authentication will fail. You can check the keytab 361*bf6873c5SCy Schubert with klist -k and kinit -k. 362*bf6873c5SCy Schubert 363*bf6873c5SCy Schubert Be sure that all libraries and modules, including PAM modules, loaded by 364*bf6873c5SCy Schubert a program use the same Kerberos libraries. Sometimes programs that use 365*bf6873c5SCy Schubert PAM, such as current versions of OpenSSH, also link against Kerberos 366*bf6873c5SCy Schubert directly. If your sshd is linked against one set of Kerberos libraries 367*bf6873c5SCy Schubert and pam-krb5 is linked against a different set of Kerberos libraries, 368*bf6873c5SCy Schubert this will often cause problems (such as segmentation faults, bus errors, 369*bf6873c5SCy Schubert assertions, or other strange behavior). Similar issues apply to the 370*bf6873c5SCy Schubert com_err library or any other library used by both modules and shared 371*bf6873c5SCy Schubert libraries and by the application that loads them. If your OS ships 372*bf6873c5SCy Schubert Kerberos libraries, it's usually best if possible to build all Kerberos 373*bf6873c5SCy Schubert software on the system against those libraries. 374*bf6873c5SCy Schubert 375*bf6873c5SCy SchubertIMPLEMENTATION NOTES 376*bf6873c5SCy Schubert 377*bf6873c5SCy Schubert The normal sequence of actions taken for a user login is: 378*bf6873c5SCy Schubert 379*bf6873c5SCy Schubert pam_authenticate 380*bf6873c5SCy Schubert pam_setcred(PAM_ESTABLISH_CRED) 381*bf6873c5SCy Schubert pam_open_session 382*bf6873c5SCy Schubert pam_acct_mgmt 383*bf6873c5SCy Schubert 384*bf6873c5SCy Schubert and then at logout: 385*bf6873c5SCy Schubert 386*bf6873c5SCy Schubert pam_close_session 387*bf6873c5SCy Schubert 388*bf6873c5SCy Schubert followed by closing the open PAM session. The corresponding pam_sm_* 389*bf6873c5SCy Schubert functions in this module are called when an application calls those 390*bf6873c5SCy Schubert public interface functions. Not all applications call all of those 391*bf6873c5SCy Schubert functions, or in particularly that order, although pam_authenticate is 392*bf6873c5SCy Schubert always first and has to be. 393*bf6873c5SCy Schubert 394*bf6873c5SCy Schubert When pam_authenticate is called, pam-krb5 creates a temporary ticket 395*bf6873c5SCy Schubert cache in /tmp and sets the PAM environment variable PAM_KRB5CCNAME to 396*bf6873c5SCy Schubert point to it. This ticket cache will be automatically destroyed when the 397*bf6873c5SCy Schubert PAM session is closed and is there only to pass the initial credentials 398*bf6873c5SCy Schubert to the call to pam_setcred. The module would use a memory cache, but 399*bf6873c5SCy Schubert memory caches will only work if the application preserves the PAM 400*bf6873c5SCy Schubert environment between the calls to pam_authenticate and pam_setcred. Most 401*bf6873c5SCy Schubert do, but OpenSSH notoriously does not and calls pam_authenticate in a 402*bf6873c5SCy Schubert subprocess, so this method is used to pass the tickets to the 403*bf6873c5SCy Schubert pam_setcred call in a different process. 404*bf6873c5SCy Schubert 405*bf6873c5SCy Schubert pam_authenticate does a complete authentication, including checking the 406*bf6873c5SCy Schubert resulting TGT by obtaining a service ticket for the local host if 407*bf6873c5SCy Schubert possible, but this requires read access to the system keytab. If the 408*bf6873c5SCy Schubert keytab doesn't exist, can't be read, or doesn't include the appropriate 409*bf6873c5SCy Schubert credentials, the default is to accept the authentication. This can be 410*bf6873c5SCy Schubert controlled by setting verify_ap_req_nofail to true in [libdefaults] in 411*bf6873c5SCy Schubert /etc/krb5.conf. pam_authenticate also does a basic authorization check, 412*bf6873c5SCy Schubert by default calling krb5_kuserok (which uses ~/.k5login if available and 413*bf6873c5SCy Schubert falls back to checking that the principal corresponds to the account 414*bf6873c5SCy Schubert name). This can be customized with several options documented in the 415*bf6873c5SCy Schubert pam_krb5(5) man page. 416*bf6873c5SCy Schubert 417*bf6873c5SCy Schubert pam-krb5 treats pam_open_session and pam_setcred(PAM_ESTABLISH_CRED) as 418*bf6873c5SCy Schubert synonymous, as some applications call one and some call the other. Both 419*bf6873c5SCy Schubert copy the initial credentials from the temporary cache into a permanent 420*bf6873c5SCy Schubert cache for this session and set KRB5CCNAME in the environment. It will 421*bf6873c5SCy Schubert remember when the credential cache has been established and then avoid 422*bf6873c5SCy Schubert doing any duplicate work afterwards, since some applications call 423*bf6873c5SCy Schubert pam_setcred or pam_open_session multiple times (most notably X.Org 7 and 424*bf6873c5SCy Schubert earlier xdm, which also throws away the module settings the last time it 425*bf6873c5SCy Schubert calls them). 426*bf6873c5SCy Schubert 427*bf6873c5SCy Schubert pam_acct_mgmt finds the ticket cache, reads it in to obtain the 428*bf6873c5SCy Schubert authenticated principal, and then does is another authorization check 429*bf6873c5SCy Schubert against .k5login or the local account name as described above. 430*bf6873c5SCy Schubert 431*bf6873c5SCy Schubert After the call to pam_setcred or pam_open_session, the ticket cache will 432*bf6873c5SCy Schubert be destroyed whenever the calling application either destroys the PAM 433*bf6873c5SCy Schubert environment or calls pam_close_session, which it should do on user 434*bf6873c5SCy Schubert logout. 435*bf6873c5SCy Schubert 436*bf6873c5SCy Schubert The normal sequence of events when refreshing a ticket cache (such as 437*bf6873c5SCy Schubert inside a screensaver) is: 438*bf6873c5SCy Schubert 439*bf6873c5SCy Schubert pam_authenticate 440*bf6873c5SCy Schubert pam_setcred(PAM_REINITIALIZE_CRED) 441*bf6873c5SCy Schubert pam_acct_mgmt 442*bf6873c5SCy Schubert 443*bf6873c5SCy Schubert (PAM_REFRESH_CRED may be used instead.) Authentication proceeds as 444*bf6873c5SCy Schubert above. At the pam_setcred stage, rather than creating a new ticket 445*bf6873c5SCy Schubert cache, the module instead finds the current ticket cache (from the 446*bf6873c5SCy Schubert KRB5CCNAME environment variable or the default ticket cache location 447*bf6873c5SCy Schubert from the Kerberos library) and then reinitializes it with the 448*bf6873c5SCy Schubert credentials from the temporary pam_authenticate ticket cache. When 449*bf6873c5SCy Schubert refreshing a ticket cache, the application should not open a session. 450*bf6873c5SCy Schubert Calling pam_acct_mgmt is optional; pam-krb5 doesn't do anything 451*bf6873c5SCy Schubert different when it's called in this case. 452*bf6873c5SCy Schubert 453*bf6873c5SCy Schubert If pam_authenticate apparently didn't succeed, or if an account was 454*bf6873c5SCy Schubert configured to be ignored via ignore_root or minimum_uid, pam_setcred 455*bf6873c5SCy Schubert (and therefore pam_open_session) and pam_acct_mgmt return PAM_IGNORE, 456*bf6873c5SCy Schubert which tells the PAM library to proceed as if that module wasn't listed 457*bf6873c5SCy Schubert in the PAM configuration at all. pam_authenticate, however, returns 458*bf6873c5SCy Schubert failure in the ignored user case by default, since otherwise a 459*bf6873c5SCy Schubert configuration using ignore_root with pam-krb5 as the only PAM module 460*bf6873c5SCy Schubert would allow anyone to log in as root without a password. There doesn't 461*bf6873c5SCy Schubert appear to be a case where returning PAM_IGNORE instead would improve the 462*bf6873c5SCy Schubert module's behavior, but if you know of a case, please let me know. 463*bf6873c5SCy Schubert 464*bf6873c5SCy Schubert By default, pam_authenticate intentionally does not follow the PAM 465*bf6873c5SCy Schubert standard for handling expired accounts and instead returns failure from 466*bf6873c5SCy Schubert pam_authenticate unless the Kerberos libraries are able to change the 467*bf6873c5SCy Schubert account password during authentication. Too many applications either do 468*bf6873c5SCy Schubert not call pam_acct_mgmt or ignore its exit status. The fully correct PAM 469*bf6873c5SCy Schubert behavior (returning success from pam_authenticate and 470*bf6873c5SCy Schubert PAM_NEW_AUTHTOK_REQD from pam_acct_mgmt) can be enabled with the 471*bf6873c5SCy Schubert defer_pwchange option. 472*bf6873c5SCy Schubert 473*bf6873c5SCy Schubert The defer_pwchange option is unfortunately somewhat tricky to implement. 474*bf6873c5SCy Schubert In this case, the calling sequence is: 475*bf6873c5SCy Schubert 476*bf6873c5SCy Schubert pam_authenticate 477*bf6873c5SCy Schubert pam_acct_mgmt 478*bf6873c5SCy Schubert pam_chauthtok 479*bf6873c5SCy Schubert pam_setcred 480*bf6873c5SCy Schubert pam_open_session 481*bf6873c5SCy Schubert 482*bf6873c5SCy Schubert During the first pam_authenticate, we can't obtain credentials and 483*bf6873c5SCy Schubert therefore a ticket cache since the password is expired. But 484*bf6873c5SCy Schubert pam_authenticate isn't called again after pam_chauthtok, so 485*bf6873c5SCy Schubert pam_chauthtok has to create a ticket cache. We however don't want it to 486*bf6873c5SCy Schubert do this for the normal password change (passwd) case. 487*bf6873c5SCy Schubert 488*bf6873c5SCy Schubert What we do is set a flag in our PAM data structure saying that we're 489*bf6873c5SCy Schubert processing an expired password, and pam_chauthtok, if it sees that flag, 490*bf6873c5SCy Schubert redoes the authentication with password prompting disabled after it 491*bf6873c5SCy Schubert finishes changing the password. 492*bf6873c5SCy Schubert 493*bf6873c5SCy Schubert Unfortunately, when handling password changes this way, pam_chauthtok 494*bf6873c5SCy Schubert will always have to prompt the user for their current password again 495*bf6873c5SCy Schubert even though they just typed it. This is because the saved 496*bf6873c5SCy Schubert authentication tokens are cleared after pam_authenticate returns, for 497*bf6873c5SCy Schubert security reasons. We could hack around this by saving the password in 498*bf6873c5SCy Schubert our PAM data structure, but this would let the application gain access 499*bf6873c5SCy Schubert to it (exactly what the clearing is intended to prevent) and breaks a 500*bf6873c5SCy Schubert PAM library guarantee. We could also work around this by having 501*bf6873c5SCy Schubert pam_authenticate get the kadmin/changepw authenticator in the expired 502*bf6873c5SCy Schubert password case and store it for pam_chauthtok, but it doesn't seem worth 503*bf6873c5SCy Schubert the hassle. 504*bf6873c5SCy Schubert 505*bf6873c5SCy SchubertHISTORY AND ACKNOWLEDGEMENTS 506*bf6873c5SCy Schubert 507*bf6873c5SCy Schubert Originally written by Frank Cusack <fcusack@fcusack.com>, with the 508*bf6873c5SCy Schubert following acknowledgement: 509*bf6873c5SCy Schubert 510*bf6873c5SCy Schubert Thanks to Naomaru Itoi <itoi@eecs.umich.edu>, Curtis King 511*bf6873c5SCy Schubert <curtis.king@cul.ca>, and Derrick Brashear <shadow@dementia.org>, all 512*bf6873c5SCy Schubert of whom have written and made available Kerberos 4/5 modules. 513*bf6873c5SCy Schubert Although no code in this module is directly from these author's 514*bf6873c5SCy Schubert modules, (except the get_user_info() routine in support.c; derived 515*bf6873c5SCy Schubert from whichever of these authors originally wrote the first module the 516*bf6873c5SCy Schubert other 2 copied from), it was extremely helpful to look over their code 517*bf6873c5SCy Schubert which aided in my design. 518*bf6873c5SCy Schubert 519*bf6873c5SCy Schubert The module was then patched for the FreeBSD ports collection with 520*bf6873c5SCy Schubert additional modifications by unknown maintainers and then was modified by 521*bf6873c5SCy Schubert Joel Kociolek <joko@logidee.com> to be usable with Debian GNU/Linux. 522*bf6873c5SCy Schubert 523*bf6873c5SCy Schubert It was packaged by Sam Hartman as the Kerberos v5 PAM module for Debian 524*bf6873c5SCy Schubert and improved and modified by him and later by Russ Allbery to fix bugs 525*bf6873c5SCy Schubert and add additional features. It was then adopted by Andres Salomon, who 526*bf6873c5SCy Schubert added support for refreshing credentials. 527*bf6873c5SCy Schubert 528*bf6873c5SCy Schubert The current distribution is maintained by Russ Allbery, who also added 529*bf6873c5SCy Schubert support for reading configuration from krb5.conf, added many features 530*bf6873c5SCy Schubert for compatibility with the Sourceforge module, commented and 531*bf6873c5SCy Schubert standardized the formatting of the code, and overhauled the 532*bf6873c5SCy Schubert documentation. 533*bf6873c5SCy Schubert 534*bf6873c5SCy Schubert Thanks to Douglas E. Engert for the initial implementation of PKINIT 535*bf6873c5SCy Schubert support. I have since modified and reworked it extensively, so any bugs 536*bf6873c5SCy Schubert or compilation problems are my fault. 537*bf6873c5SCy Schubert 538*bf6873c5SCy Schubert Thanks to Markus Moeller for lots of debugging and multiple patches and 539*bf6873c5SCy Schubert suggestions for improved portability. 540*bf6873c5SCy Schubert 541*bf6873c5SCy Schubert Thanks to Booker Bense for the implementation of the alt_auth_map 542*bf6873c5SCy Schubert option. 543*bf6873c5SCy Schubert 544*bf6873c5SCy Schubert Thanks to Sam Hartman for the FAST support implementation. 545*bf6873c5SCy Schubert 546*bf6873c5SCy SchubertSUPPORT 547*bf6873c5SCy Schubert 548*bf6873c5SCy Schubert The pam-krb5 web page at: 549*bf6873c5SCy Schubert 550*bf6873c5SCy Schubert https://www.eyrie.org/~eagle/software/pam-krb5/ 551*bf6873c5SCy Schubert 552*bf6873c5SCy Schubert will always have the current version of this package, the current 553*bf6873c5SCy Schubert documentation, and pointers to any additional resources. 554*bf6873c5SCy Schubert 555*bf6873c5SCy Schubert For bug tracking, use the issue tracker on GitHub: 556*bf6873c5SCy Schubert 557*bf6873c5SCy Schubert https://github.com/rra/pam-krb5/issues 558*bf6873c5SCy Schubert 559*bf6873c5SCy Schubert However, please be aware that I tend to be extremely busy and work 560*bf6873c5SCy Schubert projects often take priority. I'll save your report and get to it as 561*bf6873c5SCy Schubert soon as I can, but it may take me a couple of months. 562*bf6873c5SCy Schubert 563*bf6873c5SCy SchubertSOURCE REPOSITORY 564*bf6873c5SCy Schubert 565*bf6873c5SCy Schubert pam-krb5 is maintained using Git. You can access the current source on 566*bf6873c5SCy Schubert GitHub at: 567*bf6873c5SCy Schubert 568*bf6873c5SCy Schubert https://github.com/rra/pam-krb5 569*bf6873c5SCy Schubert 570*bf6873c5SCy Schubert or by cloning the repository at: 571*bf6873c5SCy Schubert 572*bf6873c5SCy Schubert https://git.eyrie.org/git/kerberos/pam-krb5.git 573*bf6873c5SCy Schubert 574*bf6873c5SCy Schubert or view the repository via the web at: 575*bf6873c5SCy Schubert 576*bf6873c5SCy Schubert https://git.eyrie.org/?p=kerberos/pam-krb5.git 577*bf6873c5SCy Schubert 578*bf6873c5SCy Schubert The eyrie.org repository is the canonical one, maintained by the author, 579*bf6873c5SCy Schubert but using GitHub is probably more convenient for most purposes. Pull 580*bf6873c5SCy Schubert requests are gratefully reviewed and normally accepted. 581*bf6873c5SCy Schubert 582*bf6873c5SCy SchubertLICENSE 583*bf6873c5SCy Schubert 584*bf6873c5SCy Schubert The pam-krb5 package as a whole is covered by the following copyright 585*bf6873c5SCy Schubert statement and license: 586*bf6873c5SCy Schubert 587*bf6873c5SCy Schubert Copyright 2005-2010, 2014-2015, 2017, 2020-2021 588*bf6873c5SCy Schubert Russ Allbery <eagle@eyrie.org> 589*bf6873c5SCy Schubert Copyright 2009-2011 590*bf6873c5SCy Schubert The Board of Trustees of the Leland Stanford Junior University 591*bf6873c5SCy Schubert Copyright 2005 Andres Salomon <dilinger@debian.org> 592*bf6873c5SCy Schubert Copyright 1999-2000 Frank Cusack <fcusack@fcusack.com> 593*bf6873c5SCy Schubert 594*bf6873c5SCy Schubert Redistribution and use in source and binary forms, with or without 595*bf6873c5SCy Schubert modification, are permitted provided that the following conditions are 596*bf6873c5SCy Schubert met: 597*bf6873c5SCy Schubert 598*bf6873c5SCy Schubert 1. Redistributions of source code must retain the above copyright 599*bf6873c5SCy Schubert notice, and the entire permission notice in its entirety, including 600*bf6873c5SCy Schubert the disclaimer of warranties. 601*bf6873c5SCy Schubert 602*bf6873c5SCy Schubert 2. Redistributions in binary form must reproduce the above copyright 603*bf6873c5SCy Schubert notice, this list of conditions and the following disclaimer in the 604*bf6873c5SCy Schubert documentation and/or other materials provided with the 605*bf6873c5SCy Schubert distribution. 606*bf6873c5SCy Schubert 607*bf6873c5SCy Schubert 3. The name of the author may not be used to endorse or promote 608*bf6873c5SCy Schubert products derived from this software without specific prior written 609*bf6873c5SCy Schubert permission. 610*bf6873c5SCy Schubert 611*bf6873c5SCy Schubert ALTERNATIVELY, this product may be distributed under the terms of the 612*bf6873c5SCy Schubert GNU General Public License, in which case the provisions of the GPL 613*bf6873c5SCy Schubert are required INSTEAD OF the above restrictions. (This clause is 614*bf6873c5SCy Schubert necessary due to a potential bad interaction between the GPL and the 615*bf6873c5SCy Schubert restrictions contained in a BSD-style copyright.) 616*bf6873c5SCy Schubert 617*bf6873c5SCy Schubert THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 618*bf6873c5SCy Schubert WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 619*bf6873c5SCy Schubert MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 620*bf6873c5SCy Schubert IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 621*bf6873c5SCy Schubert INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 622*bf6873c5SCy Schubert BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 623*bf6873c5SCy Schubert OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 624*bf6873c5SCy Schubert ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 625*bf6873c5SCy Schubert TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 626*bf6873c5SCy Schubert USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 627*bf6873c5SCy Schubert DAMAGE. 628*bf6873c5SCy Schubert 629*bf6873c5SCy Schubert Some files in this distribution are individually released under 630*bf6873c5SCy Schubert different licenses, all of which are compatible with the above general 631*bf6873c5SCy Schubert package license but which may require preservation of additional 632*bf6873c5SCy Schubert notices. All required notices, and detailed information about the 633*bf6873c5SCy Schubert licensing of each file, are recorded in the LICENSE file. 634*bf6873c5SCy Schubert 635*bf6873c5SCy Schubert Files covered by a license with an assigned SPDX License Identifier 636*bf6873c5SCy Schubert include SPDX-License-Identifier tags to enable automated processing of 637*bf6873c5SCy Schubert license information. See https://spdx.org/licenses/ for more 638*bf6873c5SCy Schubert information. 639*bf6873c5SCy Schubert 640*bf6873c5SCy Schubert For any copyright range specified by files in this package as YYYY-ZZZZ, 641*bf6873c5SCy Schubert the range specifies every single year in that closed interval. 642