我正在使用Fail2Ban来监控各种日志。我使用的是来自Anthony Martin的AWS ACL Fail2Ban https://github.com/anthonymartin/aws-acl-fail2ban。
当操作调用外部脚本时,将引发以下错误:
2018-04-10 23:25:32,426 fail2ban.action [5638]: DEBUG /opt/AWS_ACL_Fail2Ban/aws-acl-fail2ban -i acl-e05a8898 -b 50.97.23.5 -- stderr: b'Traceback (most recent call last):
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 26, in <module>
from awscli.formatter import get_formatter
File "/usr/lib/python3/dist-packages/awscli/formatter.py", line 19, in <module>
from awscli.table import MultiTable, Styler, ColorizedStyler
File "/usr/lib/python3/dist-packages/awscli/table.py", line 19, in <module>
from awscli.compat import six
File "/usr/lib/python3/dist-packages/awscli/compat.py", line 69, in <module>
binary_stdin = sys.stdin.buffer
AttributeError: \'NoneType\' object has no attribute \'buffer\'
`Traceback (most recent call last):
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 26, in <module>
from awscli.formatter import get_formatter
File "/usr/lib/python3/dist-packages/awscli/formatter.py", line 19, in <module>
from awscli.table import MultiTable, Styler, ColorizedStyler
File "/usr/lib/python3/dist-packages/awscli/table.py", line 19, in <module>
from awscli.compat import six
File "/usr/lib/python3/dist-packages/awscli/compat.py", line 69, in <module>
binary_stdin = sys.stdin.buffer
AttributeError: \'NoneType\' object has no attribute \'buffer\'
`Traceback (most recent call last):
File "/usr/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 26, in <module>
from awscli.formatter import get_formatter
File "/usr/lib/python3/dist-packages/awscli/formatter.py", line 19, in <module>
from awscli.table import MultiTable, Styler, ColorizedStyler
File "/usr/lib/python3/dist-packages/awscli/table.py", line 19, in <module>
from awscli.compat import six
File "/usr/lib/python3/dist-packages/awscli/compat.py", line 69, in <module>
binary_stdin = sys.stdin.buffer
AttributeError: \'NoneType\' object has no attribute \'buffer\'
`'
2018-04-10 23:25:32,426 fail2ban.action [5638]: DEBUG /opt/AWS_ACL_Fail2Ban/aws-acl-fail2ban -i acl-e05a8898 -b 50.97.23.5 -- returned successfully
这是行动档案:
# Fail2Ban configuration file
#
# IMPORTANT: Update actionban and actionunban with path to
# Author: Anthony Martin
#
#
[Definition]
# Option: actionban
# Notes.: command executed when banning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: See jail.conf(5) man page
# Values: CMD
#
actionban = /opt/AWS_ACL_Fail2Ban/aws-acl-fail2ban -i acl-e05a8898 -b <ip>
# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: See jail.conf(5) man page
# Values: CMD
#
actionunban = /opt/AWS_ACL_Fail2Ban/aws-acl-fail2ban -i acl-e05a8898 -u <ip>
actionstart =
actioncheck =
actionstop =
服务器详细信息:
Ubuntu 16.04
Python 2.7.12
Python 3.5.2
当我从命令行执行命令/opt/AWS_ACL_Fail2Ban/aws-acl-fail2ban -i acl-e05a8898 -u 50.97.23.5
时,它按预期工作。只有在Fail2Ban调用它时才会出现Python错误。
有人可以告诉我如何在动作文件中输入命令吗?
谢谢。