Ubuntu - How to open ssh port with ufw

  • Last updated: Nov 3, 2023
  • Views: 808
  • Author: Admin
Ubuntu - How to open ssh port with ufw

Hello colleagues.

After you have deployed a new Ubuntu server or your provider provided you with a server, then the protection (Firewall) on the server is turned off by default. Your server is vulnerable to any external influence, and we must enable this protection. Before turning on the Firewall on the server, we first need to provide a connection to this server via the SSH protocol on port 22 . In Ubuntu and Debian operating systems, the iptables utility for managing Firewall rules is quite often used to manage the firewall, but we will use a simplified Firewall rules management interface called UFW (Uncomplicated Firewall). In Ubuntu, the UFW interface is usually present by default.

 

At the first stage, let's see the list of all applications registered in the firewall (Firewall), for this we will use the command:

$. sudo ufw app list

open port ssh

We are interested in OpenSSH applications .


 

At the next stage, we must write a rule in the Firewall that will give us the opportunity to connect to the server via the SSH protocol.

$. sudo ufw allow OpenSSH

open port ssh


 

After we have added an allow rule to the Firewall, now in the same session we must enable the Firewall, for this we will use the command:

$. sudo ufw enable

open port ssh

We confirm the inclusion of the Firewall.


 

At the last stage, let's check all the rules that are currently in the Firewall, for this we will use the command:

$. sudo ufw status

open port ssh

How can we now see that the Firewall is active on our server, and we have successfully registered the rules on OpenSSH, which means that we can now connect to the server on port 22.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

Firewall open port 80 443 on Linux CentOS/RHEL 8/7

Firewall open port 80 443 on Linux CentOS/RHEL 8/7

How to disable Firewall in Linux

How to disable Firewall in Linux

Firewall - How to see open ports in Linux

Firewall - How to see open ports in Linux