去掉message日志文件中su命令的记录
admin
2023-03-18 22:25:15
0

脚本执行需要root权限,但脚本中使用su命令来执行其他命令或脚本,比如使用nginx用户调用日志统计脚本。

去掉message日志文件中su命令的记录

在/var/log/message日志中有过多的日志显示

Jun 28 10:28:06 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:06 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:06 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:07 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none
Jun 28 10:28:08 localhost su: (to nginx) chuangyw on none

严重影响message的阅读和过滤;

计划将信息重新建立一个文件保存比如/var/log/su

修改/etc/rsyslog.conf

在message条目中添加:

auth.none

增加条目:

auth.*     /var/log/su

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none;auth.none                /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                              /var/log/secure
auth.*                                                  /var/log/su
# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog


记得重启rsyslog生效

systemctl restart rsyslog.service



相关内容

热门资讯

宏福苑母亲节晚宴,女儿希望火中... 凤凰卫视记者在香港报道:有慈善机构为大埔宏福苑居民举办母亲节晚宴,参加的居民表示,经历大火后更深刻体...
顺风车乘客拒付高速费,00后车... 近日,江苏苏州一00后车主接了一单顺风车,车主称下单时乘客已经点击确定承担全部高速费,可下高速时乘客...
圣罗兰“拉黑”杭州一条街道?记... 澎湃新闻记者 王选辉 实习生 俞涵因“恶意退货太多整条街道被商家拉黑”一事持续发酵,近日有网友反映,...
局地可达35℃以上!今年首轮高... 热起来了!今天(10日)起至13日,北方迎来今年首场大范围高温天气,大部地区气温将超30℃,刷新今年...
炒股精神病院去年被罚117万,... 精神病院作为投资主体,而且在云谲波诡的股市里打拼得很好,本身就是一个让人好奇的事情。现在既然投资行为...
这个法国人,真让人刮目相看 政坛老将,第四次冲击总统宝座。更让人刮目相看的,是他对华的清醒表态他就是梅朗雄,法国左翼政党的领导人...
台“军购条例”大幅缩水,美国果... 【文/观察者网 王恺雯】台立法机构5月8日表决通过蓝白版“军购特别条例”,预算上限由赖清德当局要求的...
奋斗华章丨平凡亦有光 奋斗即力... 奋斗华章丨平凡亦有光 奋斗即力量 五月的风,裹挟着劳动的滚烫与青春的赤诚,吹遍华夏大地。 当五一劳...
中国移动发布Token运营生态... 5月8日,中国移动在2026移动云大会期间举办“词元聚力 智享未来”Token运营发展论坛,联合腾讯...