为失败的 root ssh 禁止 OSSEC 电子邮件

tkr*_*car 3 ubuntu authentication ossec ubuntu-12.10

我在 Ubuntu 12.10 服务器上将 OSSEC 作为 HIDS 运行,它经常(每天 3-4 次)向我发送这样的通知:(注意 IP 地址的最后一个八位字节已更改为“xxx”以保护有罪)

OSSEC HIDS Notification.
2013 Nov 21 15:10:43

Received From: localhost->/var/log/auth.log
Rule: 2502 fired (level 10) -> "User missed the password more than one time"
Portion of the log(s):

Nov 21 15:10:41 localhost sshd[3594]: PAM 5 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.147.74.xxx user=root

--END OF NOTIFICATION
Run Code Online (Sandbox Code Playgroud)

我是服务器上唯一的(合法)用户,并且我已经PermitRootLogin no在我的/etc/ssh/sshd_config. 因此,每次有人无法以 root 身份登录时向我发送警报是毫无意义的。

我发现 OSSEC 规则 2502 的定义/var/ossec/rules/syslog_rules.xml如下:

  <rule id="2502" level="10">
    <match>more authentication failures;|REPEATED login failures</match>
    <description>User missed the password more than one time</description>
    <group>authentication_failed,</group>
  </rule>
Run Code Online (Sandbox Code Playgroud)

我不希望完全禁用此规则,因为知道是否有尝试登录失败的用户名会非常有帮助。当有问题的用户名是 root 时,我只需要它不给我发送电子邮件。

小智 7

将以下内容添加到您的 ´/var/ossec/rules/local_rules.xml`。

<rule id="100001" level="10">
  <if_sid>2502</if_sid>
  <description>Suppress email from failed login attempts</description>
  <options>no_email_alert</options>
</rule>
Run Code Online (Sandbox Code Playgroud)

这样,警报 ( <options>no_email_alert</options>)不会发送电子邮件,但它仍被标记为 10 级并触发适当的主动响应。