Red Hat Training

A Red Hat training course is available for RHEL 8

44.7. sudo 的 GSSAPI 身份验证故障排除

如果您无法使用 IdM 的 Kerberos ticket 对 sudo 服务进行身份验证,请使用以下情况对您的配置进行故障排除。

先决条件

流程

  • 如果您看到以下错误,Kerberos 服务可能无法根据主机名为服务票据解析正确的域:

    Server not found in Kerberos database

    在这种情况下,将主机名直接添加到 /etc/krb5.conf Kerberos 配置文件中的 [domain_realm] 部分:

    [idm-user@idm-client ~]$ cat /etc/krb5.conf
    ...
    
    [domain_realm]
     .example.com = EXAMPLE.COM
     example.com = EXAMPLE.COM
     server.example.com = EXAMPLE.COM
  • 如果您看到以下错误,则没有任何 Kerberos 凭证:

    No Kerberos credentials available

    在这种情况下,使用 kinit 工具检索 Kerberos 凭证,或者通过 SSSD 验证:

    [idm-user@idm-client ~]$ kinit idm-user@IDM.EXAMPLE.COM
    Password for idm-user@idm.example.com:
  • 如果您在 /var/log/sssd/sssd_pam.log 日志文件中看到以下错误之一,Kerberos 凭证与当前登录的用户的用户名不匹配:

    User with UPN [<UPN>] was not found.
    
    UPN [<UPN>] does not match target user [<username>].

    在这种情况下,验证您使用 SSSD 进行身份验证,或考虑禁用 /etc/sssd/sssd.conf 文件中的 pam_gssapi_check_upn 选项:

    [idm-user@idm-client ~]$ cat /etc/sssd/sssd.conf
    ...
    
    pam_gssapi_check_upn = false
  • 若要进行额外的故障排除,您可以为 pam_sss_gss.so PAM 模块启用调试输出。

    • 在 PAM 文件中所有 pam_sss_gss.so 条目的末尾添加 debug 选项,如 /etc/pam.d/sudo/etc/pam.d/sudo-i

      [root@idm-client ~]# cat /etc/pam.d/sudo
      #%PAM-1.0
      auth       sufficient   pam_sss_gss.so   debug
      auth       include      system-auth
      account    include      system-auth
      password   include      system-auth
      session    include      system-auth
      [root@idm-client ~]# cat /etc/pam.d/sudo-i
      #%PAM-1.0
      auth       sufficient   pam_sss_gss.so   debug
      auth       include      sudo
      account    include      sudo
      password   include      sudo
      session    optional     pam_keyinit.so force revoke
      session    include      sudo
    • 尝试使用 pam_sss_gss.so 模块进行身份验证,并查看控制台输出。在本例中,用户没有任何 Kerberos 凭据。

      [idm-user@idm-client ~]$ sudo ls -l /etc/sssd/sssd.conf
      pam_sss_gss: Initializing GSSAPI authentication with SSSD
      pam_sss_gss: Switching euid from 0 to 1366201107
      pam_sss_gss: Trying to establish security context
      pam_sss_gss: SSSD User name: idm-user@idm.example.com
      pam_sss_gss: User domain: idm.example.com
      pam_sss_gss: User principal:
      pam_sss_gss: Target name: host@idm.example.com
      pam_sss_gss: Using ccache: KCM:
      pam_sss_gss: Acquiring credentials, principal name will be derived
      pam_sss_gss: Unable to read credentials from [KCM:] [maj:0xd0000, min:0x96c73ac3]
      pam_sss_gss: GSSAPI: Unspecified GSS failure.  Minor code may provide more information
      pam_sss_gss: GSSAPI: No credentials cache found
      pam_sss_gss: Switching euid from 1366200907 to 0
      pam_sss_gss: System error [5]: Input/output error