 apt install sudo -y
 apt install fail2ban -y

echo '[DEFAULT]
ignoreip = 127.0.0.1/8 #IP白名单
bantime = 600 #封禁时间秒，默认是10分钟
maxretry = 3 #最大重试次数，子项未设置时以此为准
[ssh]
enabled = true #启用开关
port = ssh #保护端口，默认SSH为22
filter = sshd #默认即可
logpath = /var/log/auth.log #日志位置，默认即可
maxretry = 5 #最大重试次数' >/etc/fail2ban/jail.local


 sudo service fail2ban restart

sudo fail2ban-client ping

sudo fail2ban-client status

sudo fail2ban-client status sshd