-
Install UFW:
sudo apt install ufw
-
Set default policies:
-
ufw default deny incoming
-
ufw default allow outgoing
-
-
Allow SSH:
ufw allow 22
-
Enable UFW:
ufw enable
-
Check status:
ufw status verbose
You can also allow specific ports like
ufw allow 80
(HTTP) andufw allow 443
(HTTPS).