安裝 fail2ban
yum install epel-release yum install fail2ban systemctl enable fail2ban
yum install epel-release yum install fail2ban systemctl enable fail2ban
[DEFAULT] # Ban hosts for one hour: ignoreip = 127.0.0.1/8 bantime = 86400 findtime = 600 maxretry = 10 # Override /etc/fail2ban/jail.d/00-firewalld.conf: # if you use iptables firewall use this one # banaction = iptables-multiport # if you use firewalld firewall use this one banaction = firewallcmd-ipset action = %(action_mwl)s [sshd] enabled = true filter = sshd port = 22 action = %(action_mwl)s logpath = /var/log/secure
systemctl start fail2ban
fail2ban-client status
Status |- Number of jail: 1 `- Jail list: sshd
fail2ban-client status sshd
Status for the jail: sshd |- Filter | |- Currently failed: 4 | |- Total failed: 52 | `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd `- Actions |- Currently banned: 1 |- Total banned: 1 `- Banned IP list: 218.92.1.152
fail2ban-client set sshd unbanip youripaddress