重庆思庄Oracle、Redhat认证学习论坛

标题: You (oracle) are not allowed to access to (crontab) becaus of pam configuration. [打印本页]

作者: jiawang    时间: 2025-1-2 09:17
标题: You (oracle) are not allowed to access to (crontab) becaus of pam configuration.
本帖最后由 jiawang 于 2025-1-2 09:17 编辑

oracle用户下查看计划任务时,报错如下:
--查看计划任务
[oracle@sztech ~]$ crontab -l
You (oracle) are not allowed to access to (crontab) because of pam configuration.



按照常规流程排查下,顺序如下:

1)查看/bin/crontab的SSID位是否标记S

2)检查/etc/cron* 是否设置了.deny文件限制;

3)检查PAM模块,cat /etc/pam.d/crond,文件中配置是否正常

4)查看系统日志cat /var/log/secure的错误信息

5)查看oracle用户密码过期

查看/bin/crontab的SSID位是否标记S
[root@sztech ~]# ll /bin/crontab
-rwsr-xr-x. 1 root root 57664 Oct 16  2017 /bin/crontab


检查/etc/cron 是否设置了.deny文件限制*
[root@sztech ~]# ll -dl /etc/cron*
drwxr-xr-x. 2 root root 4096 Jan 13  2020 /etc/cron.d
drwxr-xr-x. 2 root root 4096 Jan 13  2020 /etc/cron.daily
-rw-------. 1 root root    0 Oct 16  2017 /etc/cron.deny
drwxr-xr-x. 2 root root 4096 Jan 13  2020 /etc/cron.hourly
drwxr-xr-x. 2 root root 4096 Dec 28  2013 /etc/cron.monthly
-rw-r--r--. 1 root root  451 Dec 28  2013 /etc/crontab
drwxr-xr-x. 2 root root 4096 Dec 28  2013 /etc/cron.weekly
有/etc/cron.deny文件,但没有实际内容,也就不存在什么限制。


注意:


如果存在cron.allow文件,以cron.allow文件优先;如果cron.allow和cron.deny都存在,以cron.allow文件优先;如果只有cron.deny 文件,只能以cron.deny 文件为准。


检查PAM模块,cat /etc/pam.d/crond,文件中配置是否正常
[root@sztech ~]# cat /etc/pam.d/crond
#
# The PAM configuration file for the cron daemon
#
#
# No PAM authentication called, auth modules not needed
account    required   pam_access.so
account    include    password-auth
session    required   pam_loginuid.so
session    include    password-auth
auth       include    password-auth




查看系统日志cat /var/log/secure的错误信息
Mar 3 16:54:01 sztech crond[103891]: pam_unix(crond:account): expired password for user oracle (password aged)
Mar 3 16:54:25 sztech su: pam_unix(su-l:session): session opened for user root by root2(uid=1001)
Mar 3 16:55:47 sztech crontab: pam_unix(crond:account): expired password for user oracle (password aged)




Chage命令查看oracle用户密码有效期
--查看oracle用户密码有效期
[root@sztech ~]# chage -l oracle
Last password change : Aug 31, 2020
Password expires : Feb 27, 2023
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
Password expires : Feb 27, 2023部分,显示oracle的密码到期时间为Feb 27, 2023。


问题原因
oracle账号密码到期,导致oracle下的crontab的定时任务不能正常进行,所以产生如下报错:


[oracle@sztech ~]$ crontab -l
You (oracle) are not allowed to access to (crontab) because of pam configuration.
解决办法
修改oracle密码永不过期


--修改oracle密码永不过期
[root@sztech ~]# chage -M 99999 oracle

--chage -l oracle查看命令,再看密码过期时间为never
[root@sztech ~]# chage -l oracle
Last password change : Aug 31, 2020
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 10
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7Minimum number of days between password change : 10
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
经再次验证,oracle下的crontab命令可以正常编辑。








欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2