How To Install Fail2Ban on Linux Mint 21
In this tutorial, we will show you how to install the Fail2Ban on Linux Mint 21. Are you concerned about the security of your Linux Mint 21 system? If so, you’re in the right place. In today’s digital age, security should be a top priority for any computer user. Luckily, there are tools like Fail2ban that can help you protect your system against unauthorized access and brute-force attacks. Fail2ban is an open-source intrusion prevention tool that monitors system logs for suspicious activity and takes action to prevent attacks.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Fail2Ban security tool on Linux Mint 21.
Prerequisites
- A server running one of the following operating systems: Linux Mint 21.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Fail2Ban.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Fail2Ban on Linux Mint 21
Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update sudo apt install software-properties-common apt-transport-https wget ca-certificates gnupg2
Step 2. Installing Fail2Ban on Linux Mint 21.
By default, Fail2Ban is available on the Linux Mint 21 base repository. Now run the following command below to install the latest version of Fail2Ban to your Linux Mint system:
sudo apt install fail2ban
Step 3. Configuring Fail2ban on Linux Mint.
The default configuration file for Fail2ban on Linux Mint 21 is located at /etc/fail2ban/jail.conf
. However, it is recommended that you make a copy of this file and use it as a base for your own configuration file. You can do this by running the following command in your terminal:
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Next, you can edit the jail.local
file to configure Fail2ban according to your needs. Some important settings to consider are:
ignoreip
: This setting allows you to specify IP addresses that should be ignored by Fail2ban. You should add the IP address of your own machine to this list to avoid getting locked out of your server.bantime
: This setting determines how long IP addresses should be banned. The default value is 10 minutes, but you can adjust it as needed.maxretry
: This setting determines how many failed login attempts are allowed before an IP address is banned. The default value is 5, but you can adjust it as needed.
Once you have made the necessary changes to the configuration file, you can save it and restart Fail2ban by running the following commands:
sudo systemctl restart fail2ban sudo systemctl enable fail2ban
Remember to periodically check the “jail.local
” file to ensure your settings still fit your needs and be sure to review your system logs to stay informed of any potential attacks. With Fail2Ban, you can rest easier knowing your Linux Mint 21 system is well-protected against malicious intrusions.
Step 4. How to use Fail2ban.
Now that you have configured Fail2ban on your Linux Mint 21 server, it will automatically monitor log files for suspicious activity and ban IP addresses that exhibit such activity. However, you can also use Fail2ban manually to ban specific IP addresses or unban previously banned IP addresses.
- To ban an IP address manually, you can run the following command:
sudo fail2ban-client set <jail-name> banip <ip-address>
Replace <jail-name>
with the name of the jail that you want to use (e.g. ssh), and <ip-address>
with the IP address that you want to ban.
- To unban an IP address that has been previously banned, you can run the following command:
sudo fail2ban-client set <jail-name> unbanip <ip-address>
Replace <jail-name>
with the name of the jail that you want to use (e.g. ssh), and <ip-address>
with the IP address that you want to unban.
Congratulations! You have successfully installed Fail2Ban. Thanks for using this tutorial for installing the latest version of the Fail2Ban security tool on the Linux Mint system. For additional help or useful information, we recommend you check the official Fail2Ban website.