(root) 无法使用 PAM 授权用户(权限被拒绝)

(root) 无法使用 PAM 授权用户(权限被拒绝)

当跟踪 /var/log/cron 时,我注意到 cron 作业由于 PAM 权限而失败。在我的 access.conf 中,我确实有以下未注释的内容,以确保(或者我认为是确保)root 确实有权运行 cron 作业。

# User "root" should be allowed to get access via cron .. tty5 tty6.
+ : root : cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6

我使用的是 Centos 7 内核 3.10.0-693.21.1.el7.x86_64,我们已通过领域、sssd、kerberos 将其连接到我们的 Windows 活动目录实例。我的安装步骤可以在这里找到连接到 Windows AD 的最佳身份验证机制

我现在很茫然,不知道是什么原因造成的。我仔细检查了 root 密码没有过期,而且没有过期。当前的 root 访问权限是通过 Windows 安全组配置的。

任何帮助将不胜感激!

编辑 我将调试添加到 pam_access.so 的末尾并得到以下内容

crond[17411]: pam_access(crond:account): login_access: user=root, from=cron, file=/etc/security/access.conf crond[17411]: pam_access(crond:account): line 60: - : ALL EXCEPT wheel shutdown sync : LOCAL root crond[17411]: pam_access(crond:account): list_match: list=ALL EXCEPT wheel shutdown sync, item=root crond[17411]: pam_access(crond:account): user_match: tok=ALL, item=root crond[17411]: pam_access(crond:account): string_match: tok=ALL, item=root crond[17411]: pam_access(crond:account): user_match: tok=wheel, item=root crond[17411]: pam_access(crond:account): string_match: tok=wheel, item=root crond[17411]: pam_access(crond:account): user_match: tok=shutdown, item=root crond[17411]: pam_access(crond:account): string_match: tok=shutdown, item=root crond[17411]: pam_access(crond:account): user_match: tok=sync, item=root crond[17411]: pam_access(crond:account): string_match: tok=sync, item=root crond[17411]: pam_access(crond:account): user_match=1, "root" crond[17411]: pam_access(crond:account): list_match: list=LOCAL root, item=root crond[17411]: pam_access(crond:account): from_match: tok=LOCAL, item=cron crond[17411]: pam_access(crond:account): string_match: tok=LOCAL, item=cron crond[17411]: pam_access(crond:account): from_match=1, "cron" crond[17411]: pam_access(crond:account): access denied for user来自“cron”的 root

答案1

我最终将 access.conf 重新排列如下。从某种意义上说,我将 cron 条目作为配置文件中的第二个条目,这似乎正确设置了 root 访问 cron 的权限。

 #
 # Disallow non-root logins on tty1
 #
 #-:ALL EXCEPT root:tty1
 #
 # User "root" should be allowed to get access via cron .. tty5 tty6.
 + : root : cron crond :0 tty1 tty2 tty3 tty4 tty5 tty6
 #
 # Disallow console logins to all but a few accounts.
 #
 -:ALL EXCEPT wheel shutdown sync:LOCAL root

如果有人知道,但我怀疑权限是建立在配置中输入方式的基础上的。即使您通过配置中的条目获得了权限,如果该条目之前的行拒绝您访问,那么它会覆盖授予条目,因为它首先出现?

答案2

正如下一行所示:

crond[17411]: pam_access(crond:account): access denied for user root' from cron'

看来是 cron 拒绝了访问。检查您的系统中 是否有cron.allow或文件,通常在您的或目录中。如果您有一个文件,您需要在那里添加您的用户,如果您有一个文件,并且 root 列在那里,您将需要删除它。cron.deny/etc/etc/cron.dcron.allowcron.deny

相关内容