centos7.6三权分立+安全审计


前言

centos7.6三权分立+安全审计


一、思路?

准备系统、安全、审计三个管理员用户。然后通过audit服务、syslog服务以及history进行日志及操作的保留记录。

二、审计日志准备

准备日志文件转存目录:

mkdir -p /var/log/Audit-log/{old-log-syslog,old-log-audit,old-log-history}

有条件的一定要存放在单独的分区或是硬盘上。不要盲目的提高logrotate.conf文件中的分割次数,防止日志目录使用率满导致的异常情况出现。

1.syslog服务

准备日志切割文件/etc/logrotate.d/syslog

/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    daily
    dateext
    #compress
    create 640 root root 
    #delaycompress
    rotate 180
    olddir /var/log/Audit-log/old-log-syslog
    missingok
    sharedscripts
    postrotate
	/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

可以使用下述命令立即测试是否生效

logrotate -f /etc/logrotate.d/syslog

2.audit服务

准备日志切割文件/etc/logrotate.d/audit

/var/log/audit/audit.log
{
    daily
    dateext
    #compress
    create 640 root root
    #delaycompress
    rotate 180
    olddir /var/log/Audit-log/old-log-audit
    missingok
    sharedscripts
    postrotate
	/bin/kill -HUP `cat /var/run/auditd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

可以使用下述命令立即测试是否生效

logrotate -f /etc/logrotate.d/audit

3.history执行命令保存

增加保存用户操作的脚本命令
/etc/profile文件中追加一下内容

history
 USER=`whoami`
 USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
 if [ "$USER_IP" = "" ]; then
 USER_IP=`hostname`
 fi
 if [ ! -d /var/log/history ]; then
 mkdir /var/log/history
 chmod 777 /var/log/history
 fi
 if [ ! -d /var/log/history/${LOGNAME} ]; then
 mkdir /var/log/history/${LOGNAME}
 chmod 750 /var/log/history/${LOGNAME}
 fi
 export HISTSIZE=4096
 DT=`date +"%Y%m%d_%H:%M:%S"`
 export HISTFILE="/var/log/history/${LOGNAME}/${USER}@${USER_IP}_$DT"
 chmod 600 /var/log/history/${LOGNAME}/*history* 2>/dev/null

准备日志切割文件/etc/logrotate.d/history

/var/log/history/*/*
{
    daily
    create 640 root root
    rotate 180
    olddir /var/log/Audit-log/old-log-history
    missingok
    sharedscripts
    postrotate  
        /usr/bin/find /var/log/history -mindepth 2 -type f -delete
    endscript
}

可以使用下述命令立即测试是否生效

logrotate -f /etc/logrotate.d/history

三、三权分立

systemadmin 系统管理员
securityadmin 安全管理员
auditadmin 审计管理员
网上很多博主说的直接把/etc目录赋权给安全管理员,这个不太可取。但是我这里也没什么头绪。。比较尴尬。反正是不推荐大家粗暴的去赋权。

1、用户创建

useradd systemadmin
passwd systemadmin
#密码设置为:Sysadmin@2024
#设置允许su到root用户
usermod -G wheel systemadmin


useradd securityadmin
passwd securityadmin
#密码设置为:Secadmin@2024

useradd auditadmin
passwd auditadmin
#密码设置为:Audadmin@2024
#审计员追加root组为附属组
usermod -a -G root auditadmin
#设置待审计日志文件权限
chmod 640 /var/log/messages
chmod 640 /var/log/cron
chmod 640 /var/log/maillog
chmod 640 /var/log/secure
chmod 640 /var/log/spooler
chmod 640 /var/log/audit/audit.log

操作/etc/sudoers文件,在root ALL=(ALL) ALL
后添加内容

auditadmin ALL=(root)NOPASSWD: /usr/bin/cat, /usr/bin/less, /usr/bin/more,/usr/bin/tail, /usr/bin/head

总结

三权分立这里没啥好方案,审计员我感觉这样还好 有点日志可以查看。但是安全管理员完全管理/etc这个不可取。毕竟各个服务需要保证自己的配置文件的所属权。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值