A firewall is an essential part of VPS security. Here’s how to set up UFW (Uncomplicated Firewall) to protect your server:
- Install UFW:
sudo apt install ufw
- Allow SSH connections:
sudo ufw allow ssh
- Allow other needed ports (like HTTP and HTTPS):
sudo ufw allow 80,443/tcp
- Enable UFW:
sudo ufw enable
- Check status:
sudo ufw status
With UFW enabled, your VPS will have a basic but strong firewall in place.