See this tutorial for more detail.

Set the default policy:

sudo ufw default deny incoming
sudo ufw default allow outgoing

Allow SSH:

sudo ufw allow ssh

Enable UFW:

sudo ufw enable
sudo systemctl enable --now ufw

Check status:

sudo ufw status verbose