安装Fail2ban
sudo apt-get update && sudo apt-get upgrade
sudo apt install fail2ban
启动服务
sudo systemctl start fail2ban
sudo systemctl enable fail2ban
默认设置
cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
sudo nano /etc/fail2ban/fail2ban.local
配置jail.local文件
sudo nano /etc/fail2ban/jail.local
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s
banaction = iptables-multiport
maxretry = 3 #最大错误次数
findtime = 180 #多少时间内尝试(秒)
bantime = 900 #封禁时间(秒)
filter = sshd
重启fail2ban
systemctl restart fail2ban
查看日志
fail2ban-client status
fail2ban-client status sshd
Comments | NOTHING