Prerequisites
Make sure to have any distribution of the Linux operating system installed on your machine. In our example, we have Ubuntu 20.04 installed and used for this purpose. Users must have occupied the root user account or have sudo rights to do anything.
Install UFW
At the very early stage, you have to make sure that you have the UFW firewall installed and configured on your Ubuntu 20.04 Linux system.
Now, open the command-line shell from the Activity side area at the top of the desktop, or you can use the shortcut key Ctrl+Alt+T to do so. If you don’t have UFW installed, you can do so using the below-stated instructions in the shell. The sudo command requires your sudo user password to install the UFW utility in Ubuntu 20.04 Linux distribution. Write your password and tap the “Enter” key from your typewriter.
You can also use the below command to install UFW with a little change. You can see that the UFW has been installed on our Ubuntu 20.04 Linux system.
Check the UFW Status
After the installation process, you are finally able to check the activation status of the UFW firewall. For this, we have to use the simple sudo command followed by the word “ufw” and “status”, as displayed below. The output snapshot is showing that the UFW firewall is currently disabled or inactive.
Enable UFW Firewall
To further use it, we have to first enable it using the sudo command along with the words “ufw” and “enable”, as presented in the snapshot below. Now your firewall has been properly activated and is ready to use.
We can again check the status of the UFW firewall using the old status command, as shown below. You can view the output which indicates that the UFW firewall is not activated.
When the VPS is set up for IPv6, make sure to absolutely confirm that UFW is set up to handle IPv6 as well, so it can customize IPv4 mutually as well as IPv6 firewall policies. To do just that, use the following instruction to access the configuration file of the UFW firewall:
The following below output window will be popped up. You can see it has already been set to “IPv6”, so we don’t need to change anything. Just press “:q:” and quit the file.
Default Settings
Defining certain default rules for accepting and refusing connections is among the aspects that can make establishing a firewall simpler. All incoming communications are denied by default, while all outgoing communications are allowed. This ensures that anybody who tries to log into your cloud service will be unable to do so, but any program running on the server will be allowed to communicate with the external world. You may use the subsequent instructions to change UFW’s defaults:
Allow SSH and Other Connections
By providing instructions in the command-line terminal, you can alter the security policies. Both incoming communications will be rejected if we switched on the firewall right now. When you’re linked to the cloud server via SSH, this will be a challenge because you’d be signed out. To avoid this from occurring, we’ll allow SSH connections to our cloud service, as shown below. The connections are also successfully added.
For general applications, UFW has certain defaults. The illustration shown is the SSH command we used earlier. It’s essentially just an abbreviation for:
The TCP protocol is used to facilitate the communication on port 22 with this instruction, you may use the below instruction to allow connections:
Check Status
Finally, all the connections have been set. There are a lot more connections you can connect with, but we have to check the status of the UFW firewall after connecting SSH with it. The output shows the connections listed in the output.
Delete SSH and Other Connections
Now before logging out of the system, you may have to delete all the connections. For this purpose, we have to use the same sudo command with a little change. We have been using the “delete” word this time. To delete the “SSH” connection, try the below command:
Now we will be deleting the connection for tcp port number 22 as follows:
Then we will be deleting the connection for tcp port number 22 as follows:
We are disabling the status of UFW firewall by using the same sudo ufw command. It requires sudo privileges to change the status of the UFW firewall.
Upon checking the status, you can see that it’s disabled.
Conclusion
We have tried every step to allow SSH connection with the UFW firewall. We hope you can easily establish ssh connection by going through this article.
from Linux Hint https://ift.tt/2QWtcw9
0 Comments