ufw (Uncomplicated Firewall) is a simplified interface to Linux's firewall. It defines rules that allow or deny incoming traffic by port. A good practice is to deny incoming traffic by default, allow SSH before enabling the firewall, then open only the necessary ports.
Example
sudo ufw allow OpenSSH
sudo ufw enable