Sudo
sudo-ldap 僅與 !authenticate 一起使用
我正在嘗試在乾淨的 CentOS 7 docker 環境中設置 sudo-ldap。我已經成功設置了 sssd 和 PAM 身份驗證,並且可以正常工作。
但是, sudo-ldap 僅在
!authenticate
設置時才有效:dn: cn=test,ou=SUDOers,ou=People,dc=srv,dc=world objectClass: top objectClass: sudoRole cn: test sudoUser: test sudoHost: ALL sudoRunAsUser: ALL sudoCommand: ALL sudoCommand: !/bin/cp sudoOption: !authenticate
當我執行時
sudo cp
,我得到以下調試日誌:# without !authenticate sudo: searching LDAP for sudoers entries sudo: ldap sudoRunAsUser 'ALL' ... MATCH! sudo: ldap sudoCommand 'ALL' ... MATCH! sudo: ldap sudoCommand '!/bin/cp' ... MATCH! sudo: Command allowed sudo: LDAP entry: 0x55ed4d71b930 sudo: done with LDAP searches sudo: user_matches=true sudo: host_matches=true sudo: sudo_ldap_lookup(0)=0x02 [sudo] password for test: Sorry, try again. # with !authenticate sudo: searching LDAP for sudoers entries sudo: ldap sudoRunAsUser 'ALL' ... MATCH! sudo: ldap sudoCommand 'ALL' ... MATCH! sudo: Command allowed sudo: LDAP entry: 0x564d56cb9960 sudo: done with LDAP searches sudo: user_matches=true sudo: host_matches=true sudo: sudo_ldap_lookup(0)=0x02 sudo: removing reusable search result cp: missing file operand Try 'cp --help' for more information.
我可以使用密碼通過 SSH 登錄,但無法執行
sudo
命令,有誰知道出了什麼問題?附加 /etc/pam.d/system-auth (sudo 包括該文件)
#%PAM-1.0 # This file is auto-generated. # User changes will be destroyed the next time authconfig is run. auth required pam_env.so auth sufficient pam_sss.so use_first_pass auth sufficient pam_unix.so try_first_pass nullok auth required pam_deny.so account required pam_unix.so password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= password sufficient pam_sss.so use_authtok password sufficient pam_unix.so try_first_pass use_authtok nullok sha512 shadow password required pam_deny.so session optional pam_keyinit.so revoke session required pam_limits.so -session optional pam_systemd.so session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid session required pam_unix.so session optional pam_sss.so session required pam_mkhomedir.so skel=/etc/skel umask=0022
有趣的是,順序在 PAM 中確實很重要。如果 pam_unix 出現在 pam_sss 之前,它會起作用:
auth sufficient pam_unix.so try_first_pass nullok auth sufficient pam_sss.so use_first_pass password sufficient pam_unix.so try_first_pass use_authtok nullok sha512 shadow password sufficient pam_sss.so use_authtok