Prerequisites
Before enabling UFW, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
⚠️ Always allow SSH port BEFORE enabling firewall, or you will lock yourself out!
Step 1: Check Current Status
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
sudo ufw status
Step 2: Allow SSH (VERY IMPORTANT)
sudo ufw allow 22/tcp
Step 3: Allow Other Ports (Optional)
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
Step 4: Enable UFW
sudo ufw enable
Step 5: Verify
sudo ufw status verbose
Default Policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
✅ UFW firewall is now enabled and protecting your VPS.