Fail2ban防止SSH暴力破解

Fail2ban防止SSH暴力破解

安装Fail2ban时,Python版本要大于2.4
[root@localhost ~]# python -V
对于源码包安装的软件,如果进行编译安装的话,通常都要先看它的readme文件,如何进行安装......
下载地址:
https://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/f/fail2ban-0.9.6-1.el6.1.noarch.rpm

[root@localhost ~]# wget https://astuteinternet.dl.sourceforge.net/project/fail2ban/fail2ban-stable/fail2ban-0.8.11/fail2ban-0.8.11.tar.gz
[root@localhost ~]# tar -xzvf fail2ban-0.8.11.tar.gz
[root@localhost ~]# cd fail2ban-0.8.11
[root@localhost ~]# python setup.py install
[root@localhost ~]# cd files
[root@localhost ~]# cp redhat-initd /etc/init.d/fail2ban
[root@localhost ~]# chmod 755 /etc/init.d/fail2ban
[root@localhost ~]# chkconfig --add fail2ban
[root@localhost ~]# chkconfig fail2ban on
[root@localhost ~]# vim /etc/fail2ban/jail.conf
[ssh-iptables]
enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           sendmail-whois[name=SSH, dest=[email protected], sender=[email protected], sendername="Fail2Ban"]
logpath  = /var/log/secure
maxretry = 3
findtime = 300
bantime = 3600
[vsftpd-iptables]
enabled  = true
filter   = vsftpd
action   = iptables[name=VSFTPD, port=ftp, protocol=tcp]
           sendmail-whois[name=VSFTPD, dest=[email protected]]
logpath  = /var/log/messages
maxretry = 5
bantime  = 1800

清空安全日志
[root@localhost ~]# > /var/log/secure
查看安全日志
[root@localhost ~]# cat /var/log/secure
重启fail2ban
[root@localhost ~]# service fail2ban restart
查看被ban的IP
[root@localhost ~]# fail2ban-client status ssh-iptables
生成防火墙规则链
[root@localhost ~]# iptables -L -n
查看防火墙规则链
[root@localhost ~]# iptables –L
清除防火墙规则链
[root@localhost ~]# iptables –F

猜你喜欢

转载自blog.csdn.net/SERE0211/article/details/106499561
今日推荐