检查是否配置Oracle软件账户的安全策略(需要确认后加固)
注意事项及影响:
- 修改操作系统密码过期参数
- 新的规则检查 /etc/shadow 文件,最后一次Oracle 用户修改密码的时间如果与现在超过90天则不符合要求,因此现在只能修改Oracle 密码,没法规避,建议将Oracle 用户提交4a 维护
- 修改Oracle 用户密码需要与业务侧确认,最好业务自己修改
- 最新安全加固检查标准 ,检查/etc/shadow 配置脚本如下,检查resultday < 90 天,则返回合规,否则是不合规。
secondno=`date +%s` dayno=$(($secondno/86400)) cat /etc/shadow|grep '^oracle' chday=`cat /etc/shadow|grep '^oracle'|awk -F: '{print $3}'` resultday=$(($dayno-$chday)) echo 'dayno='$dayno 'chday='$chday 'resultday='$resultday if [ $resultday -le 90 ];then echo 'check result:true' else echo 'check result:false'
扫描二维码关注公众号,回复:
2876575 查看本文章
fi |
序号 |
操作内容 |
操作步骤 |
责任人 |
时间 |
1 |
查看参数 |
Root 用户下根基下面平台修改参数位置进行查看 |
|
|
2 |
Solaris |
手动修改/etc/default/passwd文件MAXWEEKS值为13 |
|
|
3 |
Aix |
手动修改/etc/security/user文件中histexpire值为13 |
|
|
4 |
Hp |
手动修改/etc/default/security文件中PASSWORD_MAXDAYS值为90 |
|
|
5 |
Redhat |
手动修改/etc/login.defs文件中PASS_MAX_DAYS值为90 |
|
|
6 |
Suse |
手动修改/etc/login.defs文件中PASS_MAX_DAYS值为90 |
|
|
7 |
所有平台 |
修改Oracle 用户密码 Passwd oracle |
|
|
上面是这边数据库的一个加固项,意思是每隔一定的期限必须修改oracle用户的密码,这个期限是90天,如果90天周期内oracle用户还是没有修改密码,这是不符合规则的。这个可以通过上面的脚本来检测,即下面脚本。
secondno=`date +%s`
dayno=$(($secondno/86400))
cat /etc/shadow|grep '^oracle'
chday=`cat /etc/shadow|grep '^oracle'|awk -F: '{print $3}'`
resultday=$(($dayno-$chday))
echo 'dayno='$dayno 'chday='$chday 'resultday='$resultday
if [ $resultday -le 90 ];then
echo 'check result:true'
else
echo 'check result:false'
fi
如果不通过则修改/etc/login.defs文件当中的PASS_MAX_DAYS,我认为通过这样的修改是正确的,下面是对login.defs文件的解释
5 |
Redhat |
手动修改/etc/login.defs文件中PASS_MAX_DAYS值为90 |
/etc/login.defs文件定义了与/etc/password和/etc/shadow配套的用户限制设定。这个文件是需要的,缺失并不会影响系统的使用,但是也许会产生意想不到的错误。
如果/etc/shadow文件里有相同的选项,则以/etc/shadow里的设置为准,也就是说/etc/shadow的配置优先级高于/etc/login.defs。
Linux下对于新添加的用户,用户密码过期时间是从 /etc/login.defs 中 PASS_MAX_DAYS 提取的,普通系统默认就是99999,
而有些安全操作系统是90。更改此处,只是让新建的用户默认密码过期时间变化,已有用户密码过期时间仍然不变。
下面来看看这个配置文件里面具体内容
[root@Database1 oracle]# cat /etc/login.defs
# Please note that the parameters in this configuration file control the
# behavior of the tools from the shadow-utils component. None of these
# tools uses the PAM mechanism, and the utilities that use PAM (such as the
# passwd command) should therefore be configured elsewhere. Refer to
# /etc/pam.d/system-auth for more information.
# *REQUIRED*
# Directory where mailboxes reside, _or_ name of file, relative to the
# home directory. If you _do_ define both, MAIL_DIR takes precedence.
# QMAIL_DIR is for Qmail
#QMAIL_DIR Maildir
MAIL_DIR /var/spool/mail --创建用户时,要在目录/var/spool/mail中创建一个用户mail文件
#MAIL_FILE .mail
# Password aging controls:
# PASS_MAX_DAYS Maximum number of days a password may be used.
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
# PASS_MIN_LEN Minimum acceptable password length.
# PASS_WARN_AGE Number of days warning given before a password expires.
PASS_MAX_DAYS 99999 --密码最大有效期
PASS_MIN_DAYS 0 --两次修改密码的最小间隔时间
PASS_MIN_LEN 5 --密码最小长度,对于root无效
PASS_WARN_AGE 7 --密码过期前多少天开始提示
# Min/max values for automatic uid selection in useradd
UID_MIN 500 --用户ID的最小值
UID_MAX 60000 --用户ID的最大值
# Min/max values for automatic gid selection in groupadd
GID_MIN 500 --组ID的最小值
GID_MAX 60000 --组ID的最大值
# If defined, this command is run when removing a user.
# It should remove any at/cron/print jobs etc. owned by
# the user to be removed (passed as the first argument).
#USERDEL_CMD /usr/sbin/userdel_local
# If useradd should create home directories for users by default
# On RH systems, we do. This option is overridden with the -m flag on
# useradd command line.
CREATE_HOME yes --使用useradd的时候是够创建用户目录
# The permission mask is initialized to this value. If not specified,
# the permission mask will be initialized to 022.
UMASK 077
# This enables userdel to remove user groups if no members exist.
USERGROUPS_ENAB yes
# Use SHA512 to encrypt password.
ENCRYPT_METHOD SHA512 --用SHA512加密密码
如果要修改oracle的修改密码的期限不要通过/etc/login.defs这个文件进行修改,因为这个文件是对所有新创建的用户生效,对oracle用户使用chage进行修改。
创建一个grid用户使用chage命令修改用户密码期限
[root@Database1 oracle]# useradd grid
[root@Database1 oracle]# chage -l grid
Last password change : May 24, 2018
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@Database1 oracle]# chage -M 6 -W 2 -I 3 grid
-M
[root@Database1 oracle]# chage -l grid
Last password change : May 24, 2018
Password expires : May 30, 2018
Password inactive : Jun 02, 2018
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 6
Number of days of warning before password expires : 2
具体的chage命令的使用请参考我的另外一篇博客:
https://blog.csdn.net/qq_34556414/article/details/81462152