UFW stands for Uncomplicated Firewall and it is an application for managing the firewall rules and IP tables efficiently. When we say that we want to limit the SSH access with UFW then we mean that generally the firewall will allow the SSH connections from all the IP addresses but if an IP address will attempt to make six or more connections within 30 seconds, then the access will be denied to it. This is done to prevent Denial of Service (DoS) or Distributed Denial of Service (DDoS) attacks on a server. In this tutorial, we will learn the procedure of limiting the SSH access with UFW on a Linux Mint 20 system.
Method of Limiting the SSH Access with UFW on Linux Mint 20:
If you wish to limit the SSH access with UFW on a Linux Mint 20 system, then you will have to perform the following steps:
Step # 1: Check if SSH is enabled on your System:
First of all, you need to verify if SSH is enabled on your system or not. For that, you will have to check its status with the command shown below:
$ sudo systemctl status ssh
You can see from the following image that SSH is enabled on our system and is actively running.
Step # 2: Install UFW on your System:
After ensuring that, you need to install UFW on your system if it is not already installed on it with the command shown below:
$ sudo apt install ufw
Step # 3: Check the Status of UFW on your System:
After installing UFW on your system successfully, you can check its status with the help of the following command:
$ sudo ufw status
If it was already installed on your system, then some rules will be already defined in it as in our case, you can see in the image shown below:
Step # 4: Limit the SSH Access with UFW on your System:
Now, we are supposed to add a new rule for limiting the SSH access on our system with the help of the following command:
$ sudo ufw limit ssh
Upon the successful execution of this command, your UFW rules will instantly be updated as shown in the image below:
Step # 5: Verify if the SSH Access has been Limited on your System or not:
After doing this, you can verify if the SSH access has been limited or not by checking its status once again with the “sudo ufw status” command. This time, you will be able to see in the output that a new UFW rule has been added that will limit the SSH access as highlighted in the following image:
With the help of this tutorial, you will be able to define a new UFW rule for limiting SSH access on your Linux Mint 20 system. Moreover, you can also try to limit access to other protocols by following the very same method.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.