How To Protect SSH With Fail2Ban on CentOS 8
To protect SSH with Fail2Ban on CentOS 8, you can follow these steps:
- Install Fail2Ban by running the command
sudo yum install fail2ban. - Create a new Fail2Ban configuration file for SSH by running the command
sudo nano /etc/fail2ban/jail.d/sshd.local. - In the file, add the following configuration:
enabled = true
port = ssh
filter = sshd
logpath = /var/log/secure
maxretry = 3- Save the file and exit.
- Start the Fail2Ban service by running the command
sudo systemctl start fail2ban. - To make sure that the service starts automatically at boot time, run the command
sudo systemctl enable fail2ban. - To check the status of the service, run the command
sudo systemctl status fail2ban. - To check the banned IPs, run the command
sudo fail2ban-client status sshd
