Allow SSH, then enable
sudo apt update
sudo apt install ufw
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status verbose
If SSH listens on a custom port: sudo ufw allow 2222/tcp (example) before enable.
Open only what the job needs
Web server examples:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw status numbered
Delete a mistaken rule by number: sudo ufw delete 3.
Default policy
Sensible defaults for a single-purpose server:
sudo ufw default deny incoming
sudo ufw default allow outgoing
Relate to Tune
Tune’s firewall step allows new connections only to the ports your acceptance test used (plus SSH), then runs your test again; if it fails, the change is put back. DIY operators should mirror that idea: open what the job needs, nothing else.
Related guides: SSH hardening on Ubuntu 22.04 · AppArmor basics · harden without breaking it.
FAQ
Will ufw cut my SSH session?
Yes if you enable the firewall before allowing OpenSSH. Always allow SSH first.
Is ufw enough alone?
It controls ports. It does not remove packages or fix weak SSH settings.
Next
Free Inaabi Scan · Subscribe to Inaabi Tune at $20 per server per month · all Inaabi guides
MinakiLabs