zoukankan      html  css  js  c++  java
  • 打赏 jQuery火箭图标返回顶部代码</h1> <div style="border: 1px solid #dfdfdf;border-top:none;"></div> <div style=" height: 200px; overflow:hidden;"> <span class="pre-scrollable"><div id="cnblogs_post_body" class="blogpost-body"> <blockquote> <p><span style="font-family: 'Microsoft YaHei';">  工作中我们常常遇到,有的员工不安于被分配的权限,老是想sudo echo "ziji" /usr/bin/visudo NOPASSWD:ALL来进行提权,造成误删了数据库某条重要的数据,或者执行了一条命令对线上生产造成了严重的影响,部门老大又苦于找不到造成这种现象的操作者,CTO对你们部门直接扣除绩效,这样你们集体成了背锅侠。。。为了记录员工做的违规操作行为,所以就有了以下的方案。</span><br /><span style="font-family: 'Microsoft YaHei';">  我们今天要学习的是:sudo日志审计,专门对使用sudo命令的系统用户记录其执行的命令相关信息,所谓日志审计,就是记录所有系统及相关用户行为的信息,并且可以自动分析,处理,展示(包括文本或着录像)</span></p> </blockquote> <h2><span style="font-family: 'Microsoft YaHei';"><span style="font-size: 14px;">一)生产环境日志审计解决方案: </span> </span></h2> <blockquote> <p><span style="font-family: 'Microsoft YaHei';">通过环境变量命令及syslog服务进行全部日志审计(信息太大,不推荐)</span></p> <p><span style="font-family: 'Microsoft YaHei';">sudo配合syslog服务,进行日志审计(信息较少,效果不错)</span></p> <p><span style="font-family: 'Microsoft YaHei';">在bash解释器程序里嵌入一个监视器,让所有被审计的系统用户使用修改过的增加了监视器的特殊bash程序作为解释程序。</span></p> <p><span style="font-family: 'Microsoft YaHei';">齐治的堡垒机:商业产品</span></p> </blockquote> <h2><span style="font-family: 'Microsoft YaHei'; font-size: 14px;">二)配置sudo日志审计</span></h2> <p><span style="font-family: 'Microsoft YaHei';">说明:所谓sudo命令日志审计,并不记录普通用户的普通操作,而是记录,那些执行sudo命令的用户的操作。</span></p> <h3><span style="font-family: 'Microsoft YaHei'; font-size: 13px;">1、安装sudo命令,rsyslog服务</span></h3> <div class="cnblogs_code"> <pre><span style="font-family: 'Microsoft YaHei';"><span style="color: #008080;user-select:none;">1</span> [root@s-<span style="color: #800080;">28</span> /]# rpm -qa|grep sudo #要是没安装执行yum install sudo -<span style="color: #000000;">y </span><span style="color: #008080;user-select:none;">2</span> sudo-<span style="color: #800080;">1.8</span>.19p2-<span style="color: #800080;">13</span><span style="color: #000000;">.el7.x86_64 </span><span style="color: #008080;user-select:none;">3</span> [root@s-<span style="color: #800080;">28</span> /]# rpm -qa|grep rsyslog #要是没安装执行yum install rsyslog -<span style="color: #000000;">y </span><span style="color: #008080;user-select:none;">4</span> rsyslog-<span style="color: #800080;">8.24</span>.<span style="color: #800080;">0</span>-<span style="color: #800080;">16</span><span style="color: #000000;">.el7.x86_64 </span><span style="color: #008080;user-select:none;">5</span> [root@s-<span style="color: #800080;">28</span> /]# </span></pre> </div> <h3><span style="font-family: 'Microsoft YaHei'; font-size: 13px;">2、配置服务</span></h3> <p><span style="font-family: 'Microsoft YaHei'; font-size: 13px;">2.1配置系统日志/etc/rsyslog.conf,增加配置local.debug到/etc/rsyslog.conf中</span></p> <div class="cnblogs_code"> <pre><span style="color: #008080;user-select:none;">1</span> [root@s-<span style="color: #800080;">28</span> /]# cat /<span style="color: #0000ff;">var</span>/log/ #查看日志文件是否存在没有就创建mkdir -p /<span style="color: #0000ff;">var</span>/<span style="color: #000000;">log </span><span style="color: #008080;user-select:none;">2</span> cat: /<span style="color: #0000ff;">var</span>/log/<span style="color: #000000;">: Is a directory </span><span style="color: #008080;user-select:none;">3</span> [root@s-<span style="color: #800080;">28</span> /]# cat /etc/redhat-<span style="color: #000000;">release </span><span style="color: #008080;user-select:none;">4</span> CentOS Linux release <span style="color: #800080;">7.5</span>.<span style="color: #800080;">1804</span><span style="color: #000000;"> (Core) </span><span style="color: #008080;user-select:none;">5</span> [root@s-<span style="color: #800080;">28</span> /]# uname -<span style="color: #000000;">r </span><span style="color: #008080;user-select:none;">6</span> <span style="color: #800080;">3.10</span>.<span style="color: #800080;">0</span>-<span style="color: #800080;">862</span><span style="color: #000000;">.el7.x86_64 </span><span style="color: #008080;user-select:none;">7</span> [root@s-<span style="color: #800080;">28</span> /]# tail -<span style="color: #800080;">1</span> /etc/rsyslog.conf #没有就执行echo <span style="color: #800000;">"</span><span style="color: #800000;">local.debug /var/log/sudo.log</span><span style="color: #800000;">"</span>>>/etc/<span style="color: #000000;">rsyslog.conf </span><span style="color: #008080;user-select:none;">8</span> local.debug /<span style="color: #0000ff;">var</span>/log/<span style="color: #000000;">sudo.log </span><span style="color: #008080;user-select:none;">9</span> [root@s-<span style="color: #800080;">28</span> /]# </pre> </div> <p>2.2配置/etc/sudoers,<span style="font-family: 'Microsoft YaHei';">增加配置 “Defaults        logfile=/var/log/sudo.log” 到/etc/sudoers中,注意:不包含引号。</span></p> <div class="cnblogs_code"> <pre><span style="color: #008080;user-select:none;">1</span> [root@s-<span style="color: #800080;">28</span> /]# echo <span style="color: #800000;">"</span><span style="color: #800000;">Defaults logfile=/var/log/sudo.log</span><span style="color: #800000;">"</span>>>/etc/<span style="color: #000000;">sudoers </span><span style="color: #008080;user-select:none;">2</span> [root@s-<span style="color: #800080;">28</span> /]# tail -<span style="color: #800080;">1</span> /etc/<span style="color: #000000;">sudoers </span><span style="color: #008080;user-select:none;">3</span> Defaults logfile=/<span style="color: #0000ff;">var</span>/log/<span style="color: #000000;">sudo.log </span><span style="color: #008080;user-select:none;">4</span> [root@s-<span style="color: #800080;">28</span> /]# visudo -<span style="color: #000000;">c </span><span style="color: #008080;user-select:none;">5</span> /etc/<span style="color: #000000;">sudoers: parsed OK </span><span style="color: #008080;user-select:none;">6</span> [root@s-<span style="color: #800080;">28</span> /]# </pre> </div> <h3><span style="font-family: 'Microsoft YaHei'; font-size: 13px;"> 3、重启syslog内核日志记录器(简单来说就是重启服务了)</span></h3> <div class="cnblogs_code"> <pre><span style="color: #008080;user-select:none;">1</span> [root@s-<span style="color: #800080;">28</span> /<span style="color: #000000;">]# systemctl restart rsyslog </span><span style="color: #008080;user-select:none;">2</span> [root@s-<span style="color: #800080;">28</span> /]# </pre> </div> <p><span style="font-family: 'Microsoft YaHei';"> 说到审计,有时候需要自定义审计规则,想了解的请参考下文哦:</span></p> <p class="col-article-title J-articleTitle">CentOS 7上编写自定义系统审计规则</p> </div> </span> </div> <div style="text-align: center;"> <a href="https://www.cnblogs.com/liang-io/p/9617783.html" target="_blank" style="font-size: 16px;background-color: rgb(24, 144, 255); color: white;padding: 8px;padding-left: 30px;padding-right: 30px;border-radius: 2rem;">查看全文</a> </div> </li> <div style="border: 1px solid #dfdfdf;border-top:none;"></div> <li class="ul-li" style="padding-left:15px;padding-right: 15px;"> <b>相关阅读:</b><br> <nobr> <a href="zno2-p-5968808.html" target="_blank">jboss hello world</a> <br/><a href="zno2-p-5968803.html" target="_blank">jboss 7 启动问题</a> <br/><a href="zno2-p-5968795.html" target="_blank">jboss [how to access the admin console]</a> <br/><a href="zno2-p-5968786.html" target="_blank">tomee 消息持久化</a> <br/><a href="linkong1081-p-4092061.html" target="_blank">Python、C和Java对比</a> <br/><a href="linkong1081-p-4074191.html" target="_blank">编程语言产生时间表</a> <br/><a href="linkong1081-p-4009287.html" target="_blank">从关系型数据库到非关系型数据库</a> <br/><a href="guchenxu-p-10158696.html" target="_blank">约束和异常处理</a> <br/><a href="guchenxu-p-10146061.html" target="_blank">类与类之间的关系</a> <br/><a href="guchenxu-p-10140047.html" target="_blank">类的成员</a> <br/> </nobr> </li> <div style="border: 1px solid #dfdfdf;border-top:none;"></div> <li class="list-group-item from-a mb-2" style="margin:15px;"> 原文地址:https://www.cnblogs.com/liang-io/p/9617783.html </li> </ul> </div> <!-- 右侧开始 --> <div class="right-kd" style="margin: auto;margin: 0px;float: left;"> <ul class="right-kd" style="word-break:break-all;border: 1px solid #dfdfdf;border-radius: 3px 3px 3px 3px;padding: 0px;margin: 0px;"> <li class="ul-li-bg ul-li-title" aria-current="true" style="padding-left:15px;padding-right: 15px;"> 最新文章 </li> <li class="ul-li" style="padding-left:15px;padding-right:15px;"> <nobr> <a href="3542446186qq-p-10122689.html" target="_blank">canvas与svg的区别</a> <br/><a href="3542446186qq-p-10115701.html" target="_blank">格式化地址栏字符串成对象</a> <br/><a href="masteryin-p-10139052.html" target="_blank">变量作用域《二》</a> <br/><a href="masteryin-p-10139042.html" target="_blank">变量的作用域 《一》</a> <br/><a href="masteryin-p-10133065.html" target="_blank">JavaScript预编译</a> <br/><a href="masteryin-p-10130231.html" target="_blank">canvas和svg区别</a> <br/><a href="masteryin-p-10110569.html" target="_blank">格式化地址栏字符串成对象</a> <br/><a href="masteryin-p-10110515.html" target="_blank">CSS3 渐变</a> <br/><a href="masteryin-p-10110136.html" target="_blank">CSS3 2d转换</a> <br/><a href="masteryin-p-10101096.html" target="_blank">多个条件的判断</a> <br/> </nobr> </li> </ul> <ul class="right-kd" style="word-break:break-all;border: 1px solid #dfdfdf;border-radius: 3px 3px 3px 3px;padding: 0px;margin-top: 10px;"> <li class="list-group-item ul-li-bg ul-li-title" aria-current="true" style="padding-left:15px;padding-right: 15px;"> 热门文章 </li> <li class="ul-li" style="padding-left:15px;padding-right: 15px;"> <nobr> <a href="masteryin-p-10101086.html" target="_blank">分支语句</a> <br/><a href="masteryin-p-10098605.html" target="_blank">三目运算符</a> <br/><a href="tangdiying-p-10098481.html" target="_blank">HTML基础标签</a> <br/><a href="tangdiying-p-10098070.html" target="_blank">web前端背景介绍</a> <br/><a href="zno2-p-7500015.html" target="_blank">java.util.HashMap</a> <br/><a href="zno2-p-7469086.html" target="_blank">dom4j 通过 org.dom4j.DocumentFactory 设置命名空间来支持 带namespace 的 xpath</a> <br/><a href="zno2-p-5970487.html" target="_blank">21)pom 中的缺省值(default properties)</a> <br/><a href="zno2-p-5968844.html" target="_blank">what is a ear</a> <br/><a href="zno2-p-5968840.html" target="_blank">lazy?</a> <br/><a href="zno2-p-5968814.html" target="_blank">jboss developers studio 快速创建 spring mvc 项目</a> <br/> </nobr> </li> </ul> </div> </div> </div> <div style="clear: both;"></div> <!-- 栅栏结束 --> <div class="kd" style="margin: auto;"> <div style="font-size:0.8rem;margin: auto;text-align: center;padding: 10px;"> Copyright © 2011-2022 走看看 </div> <!-- 引入底部 --> <!-- 百度自动推送js --> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <!-- 百度自动推送js --> </div> </div> <script src="https://common.cnblogs.com/scripts/jquery-2.2.0.min.js"></script> <script src="https://www.cnblogs.com/js/blog-common.min.js"></script> <script src="http://common.cnblogs.com/script/encoder.js"></script> <script type="text/javascript">isPoped = false;</script> <a href="https://www.aliyun.com/daily-act/ecs/activity_selection?userCode=1fogmr4h" id="redirect_url"></a> <a href="https://www.cnblogs.com/liang-io/p/9617783.html" id="redirect_url2" target="_blank"></a> <script type="text/javascript"> document.onclick = function() { if (!isPoped) { document.getElementById("redirect_url").click(); document.getElementById("redirect_url2").click(); isPoped = true; } } </script> </body> </html>