我目前正在尝试保护我们的备份服务器及其接口的安全,因为它除了强密码外没有任何其他(额外)安全性。备份服务器基于CentOS 7.x。
日志文件位置:
/var/log/backup
日志文件名:
backuplog-2019310.log
backuplog-2019309.log
backuplog-2019308.log
backuplog-2019307.log
错误的登录记录如下:
[2019-11-06T13:13:33+01:00] [Audit] Web login failure for account 'admin': Invalid authentication (Address=200.100.150.50:28534)
[2019-11-06T13:13:34+01:00] [Audit] Web login failure for account 'test': Invalid authentication (Address=120.30.40.20:28534)
[2019-11-06T13:13:35+01:00] [Audit] Web login failure for account 'info': Invalid authentication (Address=85.80.75.70:28534)
[2019-11-06T13:13:35+01:00] [Audit] Web login failure for account 'user': Invalid authentication (Address=25.125.155.190:28534)
在/etc/fail2ban/jail.local中:
[backup]
enabled = true
filter = backup
logpath = /var/log/backup/backuplog-*.log
port = 80,443
允许在其中使用星号,对吧?
到目前为止,我希望它能正确理解。
但是,我无法为此自定义的fail2ban禁止规则(=过滤器)创建正确的过滤器。
/etc/fail2ban/filter.d/backup.conf的示例:
[Definition]
failregex = [[]Web login failure for account []] .* Invalid authentication
ignoreregex =
但是它不起作用。所以我猜我的failregex不正确吗?也许有人可以建议我正确的failregex使其生效?
启动fail2ban时收到以下错误消息:
ERROR NOK: ("No 'host' group in '[[]Web login failure for account []] .* Invalid authentication'",)
所以我猜到failregex不正确吗?
//更新1-仍然存在问题+其他问题
四处游荡。这是更新的failregex:
failregex = [][] Web login failure for account .* <HOST>
现在,我不再收到“ ERROR NOK”,但是它仍然无法正常工作。这是fail2ban日志:
2019-11-06 14:44:39,111 fail2ban.filter [20978]: WARNING Unable to find a corresponding IP address for authentication: [Errno -2] Name or service not known
2019-11-06 14:44:41,706 fail2ban.filter [20978]: WARNING Unable to find a corresponding IP address for authentication: [Errno -2] Name or service not known
2019-11-06 14:44:42,082 fail2ban.filter [20978]: WARNING Unable to find a corresponding IP address for authentication: [Errno -2] Name or service not known
2019-11-06 14:44:42,623 fail2ban.filter [20978]: WARNING Unable to find a corresponding IP address for authentication: [Errno -2] Name or service not known
那我在做什么错了?
另外,考虑到这一点,我认为使用“ /var/log/backup/backuplog-*.log”不是那么好。特别是在创建越来越多的日志文件时。对吧?
是否有一种方法可以定位当前或最新的日志文件,例如backuplog-2019310.log?
先谢谢了。
与此同时,我还会胡闹更多。
//更新2-解决了主要问题!
我想我通过使用以下failregex解决了它:
failregex = Invalid authentication \(Address=<HOST>
看看我是否可以使它明显好一些。但这对我来说是一个很好的开始。
因此,也许有人可以帮助我解决上述有关日志文件的问题。为了便于阅读,我将在这里再次询问:
另外,考虑到这一点,我认为 “ /var/log/backup/backuplog-*.log”不是那么好。特别是当 创建了越来越多的日志文件。对吧?
是否有一种方法可以定位当前或最新的日志文件,例如 backuplog-2019310.log?
也许有人对此有解决方案?
谢谢。