To set up a firewall with UFW on Ubuntu 26.04, allow SSH before enabling it.
Step 1 : Update.

Step 2 : Install UFW.

Step 3 : Check status.

Step 4 : Allow SSH.

Step 5 : (Optional) Allow HTTP and HTTPS.

Step 6 : Enable.

Step 7 : Status again.

You have set up a firewall with UFW on Ubuntu 26.04.