我正在使用监控代理 ( telegraf
) 来监控 fail2ban。不幸的是,它需要超级用户权限才能执行fail2ban-client
,这会导致每 10 秒出现 24 条系统日志消息……算一算,我的系统日志绝对是混乱的。
我想在我的系统日志中隐藏这些消息,如果可能的话,只是由电报引起的:
sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
sudo: pam_unix(sudo:session): session closed for user root
我尝试使用自定义“规则”/etc/pam.d/sudo
来抑制这些消息,但没有成功:
# cat /etc/pam.d/sudo
#%PAM-1.0
session required pam_env.so readenv=1 user_readenv=0
session required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
@include common-auth
@include common-account
session [default=ignore] pam_succeed_if.so quiet uid = 0 user = root ruser = telegraf
@include common-session-noninteractive
只有以开头的行session
被添加到该文件中。该解决方案改编自How to stop auth.log for a specific user? 中的 sudo PAM 消息?
但是,日志消息仍然出现/var/log/auth.log
在journalctl -xe
我已经尝试quiet_success
过以及quiet
标志(在 中找到man pam_succeed_if
)。也使用success=1
make telegraf
fail to execute fail2ban-client
,我猜是因为它需要一个交互式 tty?
这是使用debug
标志记录的:
Sep 20 11:34:51 host sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 20 11:34:51 host sudo: pam_succeed_if(sudo:session): 'uid' resolves to '0'
Sep 20 11:34:51 host sudo: pam_succeed_if(sudo:session): 'user' resolves to 'root'
Sep 20 11:34:51 host sudo: pam_succeed_if(sudo:session): 'ruser' resolves to 'telegraf'
Sep 20 11:34:51 host sudo: pam_unix(sudo:session): session closed for user root
据我所知,“规则”正确匹配 uid、user 和 ruser,但不会抑制日志消息。我错过了重新启动,还是发生了什么?