yum -y install epel-release
yum -y install fail2ban
cp /etc/fail2ban/jail.conf /etc/fail2ban/local.conf
vim /etc/fail2ban/local.conf
在文末添加如下代码:
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=22, protocol=tcp]
#sendmail-whois[name=SSH, dest=your@email.com, sender=fail2ban@email.com]
logpath = /var/log/secure
maxretry = 3
bantime = 300
尝试次数3,如果失败,300秒内禁止连接