CentOS基线脚本,三级等保服务器系统安全配置脚本_centos 日志 等保三
echo "......[Y] Password Validity Period: $PASS_MAX_DAYS days"
else
sed -i '/PASS_MAX_DAYS/s/'"${PASS_MAX_DAYS}"'/90/g' /etc/login.defs
PASS_MAX_DAYS=cat /etc/login.defs | grep PASS_MAX_DAYS | grep -v ^# | awk '{print $2}'
if [ $PASS_MAX_DAYS -le 90 -a $PASS_MAX_DAYS -ge 30 ];then
echo “…[Y] Password Validity Period: $PASS_MAX_DAYS days”
else
echo “…[N] Password Validity Period: Reset failed”
fi
fi
}
#检查日志保留时间
function CheckLogBackupTime() {
Log_Backup_Time=cat /etc/logrotate.conf |head -n 10|grep "rotate "| grep -v ^# | head -n 1|awk '{print $2}'
if [ -z $Log_Backup_Time ];then
sed -i ‘s/#rotate/rotate/’ /etc/logrotate.conf
Log_Backup_Time=cat /etc/logrotate.conf |head -n 10|grep "rotate "| grep -v ^# | head -n 1|awk '{print $2}'
fi
if [ -z $Log_Backup_Time ];then
echo “…[N] Log backup Time,Configuration does not exist”
elif [ $Log_Backup_Time -ge 26 ];then
echo “…[Y] Log backup Time: L o g _ B a c k u p _ T i m e w e e k s " e l s e s e d − i ′ / r o t a t e / s / ′ " Log_Backup_Time weeks" else sed -i '/rotate/s/'" Log_Backup_Timeweeks"elsesed−i′/rotate/s/′"{Log_Backup_Time}”‘/26/g’ /etc/logrotate.conf
Log_Backup_Time=cat /etc/logrotate.conf |head -n 10|grep "rotate "| grep -v ^# | head -n 1|awk '{print $2}'
if [ $Log_Backup_Time -ge 26 ];then
echo “…[Y] Log backup Time: $Log_Backup_Time weeks”
else
echo “…[N] Log backup Time,Reset failed”
fi
fi
}
#检查会话超时时间
function CheckConnectionTimeout() {
Connection_Timeout=cat /etc/profile | grep 'export TMOUT' | grep -v ^# | cut -d= -f2
if [ -z C o n n e c t i o n _ T i m e o u t ] ; t h e n s e d − i ′ Connection_Timeout ];then sed -i ' Connection_Timeout];thensed−i<