您的位置:首页 > 大数据 > 人工智能

Fail2ban防止SSH暴力破解

2020-06-07 05:22 316 查看
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=you@example.com, sender=fail2ban@example.com, 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=you@example.com]
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
生成防火墙规则链
[root@localhost ~]# iptables -L -n
查看防火墙规则链
[root@localhost ~]# iptables –L
清除防火墙规则链
[root@localhost ~]# iptables –F
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: