This article provides a guide for how to install and configure Fail2ban on VPS server or Dedicated Server.
What is Fail2ban?
Fail2ban is a security tool for Linux systems that monitors log files for suspicious activity, like failed login attempts, and automatically blocks potentially harmful IP addresses. It acts as an intrusion prevention system by identifying and temporarily rejecting IP addresses that exhibit excessive or unusual behavior, thereby reducing the risk of unauthorized access.
How to Install and Configure Fail2ban
To install and configure Fail2Ban, follow the steps below:
- Login via SSH as root.
- Configure the SSH service to run on a custom port:
echo "Port 2211" >> /etc/ssh/sshd_config iptables -A INPUT -p tcp --dport 2211 -j ACCEPT systemctl restart sshd - Run the following command to install the Fail2Ban package:
sudo apt-get install fail2ban -y - Copy the default configuration:
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local - Edit the configuration:
cat <<EOF > /etc/fail2ban/jail.local [sshd] enabled = true port = 2211 EOF - Start and enable the Fail2Ban service:
systemctl restart fail2ban systemctl enable fail2ban
Conclusion
You now know how to install and configure Fail2Ban on your server.

👀 Choose SSD-powered VPS servers for increased speed, power, and security! Now 50% off- starting from only $3.19/mo.