How to Connect to Your VDS Server via SSH (Complete Guide)
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Configure a Linux server firewall using iptables and ufw: create SSH/HTTP/HTTPS rules, persist rules across reboots, and test your firewall setup effectively.
A firewall controls incoming and outgoing network traffic on your server. Linux offers two popular tools: the powerful low-level iptables and the user-friendly ufw (Uncomplicated Firewall). This guide covers both.
REXE servers include a network-level Path Panel firewall. A server-side firewall adds an extra security layer. Using both together is recommended.
iptables is the command-line tool that manages Linux kernel's netfilter framework. It handles packet filtering, NAT, and port forwarding.
# List all rules
sudo iptables -L -n -v
# List with line numbers
sudo iptables -L -n -v --line-numbers
# View NAT table
sudo iptables -t nat -L -n -v
| Concept | Description |
|---|---|
| Chain | Rule chain: INPUT, OUTPUT, FORWARD |
| Table | Rule table: filter, nat, mangle |
| Target | Rule action: ACCEPT, DROP, REJECT |
| Match | Match criteria: port, protocol, IP |
# Allow loopback interface
sudo iptables -A INPUT -i lo -j ACCEPT
# Allow established connections
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow SSH (port 22)
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Allow HTTP (port 80)
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow HTTPS (port 443)
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Drop all other incoming traffic
sudo iptables -A INPUT -j DROP
Always allow SSH before adding a DROP rule. Otherwise you will lock yourself out of the server.
# Delete by rule number
sudo iptables -D INPUT 3
# Delete by rule content
sudo iptables -D INPUT -p tcp --dport 80 -j ACCEPT
# Flush all rules
sudo iptables -F
# Allow specific IP for SSH
sudo iptables -A INPUT -s 192.168.1.100 -p tcp --dport 22 -j ACCEPT
# Block a specific IP
sudo iptables -A INPUT -s 10.0.0.5 -j DROP
# Block an IP range
sudo iptables -A INPUT -s 192.168.1.0/24 -j DROP
iptables rules are lost on reboot by default. To make them persistent:
# Install iptables-persistent
sudo apt install iptables-persistent -y
# Save current rules
sudo netfilter-persistent save
# Reload rules
sudo netfilter-persistent reload
# Install iptables-services
sudo yum install iptables-services -y
# Enable and start the service
sudo systemctl enable iptables
sudo systemctl start iptables
# Save rules
sudo service iptables save
ufw abstracts iptables complexity into simple commands. It comes pre-installed on Ubuntu and Debian.
# Install ufw
sudo apt install ufw -y
# Check status
sudo ufw status verbose
# Set default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
Always allow SSH before enabling ufw to avoid locking yourself out!
# Allow SSH
sudo ufw allow ssh
# or by port:
sudo ufw allow 22/tcp
# Allow HTTP and HTTPS
sudo ufw allow http
sudo ufw allow https
# or:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Open a custom port
sudo ufw allow 8080/tcp
# Enable ufw
sudo ufw enable
# List rules with numbers
sudo ufw status numbered
# Delete rule by number
sudo ufw delete 3
# Delete rule by content
sudo ufw delete allow 8080/tcp
# Allow from specific IP
sudo ufw allow from 192.168.1.100
# Block specific IP
sudo ufw deny from 10.0.0.5
# Disable ufw
sudo ufw disable
# Reset all rules
sudo ufw reset
ufw includes ready-made profiles for common applications:
# List available profiles
sudo ufw app list
# Enable Nginx profile
sudo ufw allow 'Nginx Full'
# Enable OpenSSH profile
sudo ufw allow 'OpenSSH'
# Scan specific ports from another machine
nmap -sT -p 22,80,443 SERVER_IP
# Scan all ports
nmap -sT SERVER_IP
# List listening TCP ports
sudo ss -tlnp
# List all connections
sudo ss -tunap
# Test specific port
telnet SERVER_IP 80
# Test with nc
nc -zv SERVER_IP 443
# HTTP test with curl
curl -I http://SERVER_IP
Apply the principle of least privilege: only open ports that are actually needed.
iptables -L or ufw status# Save iptables rules to file
sudo iptables-save > /etc/iptables/rules.v4
# Restore from file
sudo iptables-restore < /etc/iptables/rules.v4
iptables offers power and flexibility while ufw provides speed and simplicity. Beginners should start with ufw; advanced configurations benefit from iptables. Both tools work alongside REXE's Path Panel firewall. Review your firewall rules regularly and close any ports that are no longer needed.
Yes, iptables rules are temporary by default. To persist them on Debian/Ubuntu, install iptables-persistent with 'sudo apt install iptables-persistent' and save with 'sudo netfilter-persistent save'. ufw rules are automatically persistent.
ufw is better for beginners and standard use cases — commands are simpler and the risk of mistakes is lower. Use iptables for complex scenarios like custom NAT, port forwarding, or advanced packet filtering.
Path Panel operates at the network level (upstream) and filters traffic before it reaches your server — ideal for DDoS protection and large-scale blocking. Server-side firewall (iptables/ufw) operates at the OS level and provides fine-grained rule management. Using both together gives the best security.
Access your server via VNC/KVM console from the REXE customer panel. From the console, run 'sudo iptables -F' or 'sudo ufw disable' to clear the rules.
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Complete guide to connecting to Windows Server VDS via Remote Desktop (RDP): setup steps, NLA security, Path Panel firewall rule, and troubleshooting tips.
Step-by-step guide to changing your VDS server OS via REXE panel: backup tips, supported Linux distributions and Windows Server versions explained.