Instead of allowing SSH (port 22) from anywhere (0.0.0.0/0), specify only trusted IP addresses or IP ranges.
Inbound Rule:
- Type: SSH
- Protocol: TCP
- Port Range: 22
- Source:
sudo ufw status verbose # View current firewall status and rules sudo ufw status # Check if UFW is enabled
sudo ufw allow 22/tcp # Allow SSH (port 22) from any IP sudo ufw allow from x.x.x.x to any port 22 # Allow SSH from specific IP (replace x.x.x.x with IP)