Virtarix documentation

Configure a VPS firewall and keep remote access

Always open the browser Console and allow your actual SSH or RDP port before enabling UFW, firewalld or Windows Firewall rules. Test a second login in a new window before closing your existing session, and use Console to fix the rule if you get locked out.

1. Check your SSH or RDP port and open Console

In the client area, select your VPS on Dashboard and open Console. Keep both Console and your existing SSH or RDP session open while editing firewall rules.

Check which TCP port your SSH or RDP service is actually listening on. Use Administrator PowerShell for the Windows check:

Inside the VPSFind the ports used by SSH and RDPUbuntu / DebianBash
sudo ss -lntp
Inside the VPSFind the ports used by SSH and RDPWindowsPowerShell
Get-NetTCPConnection -State Listen |
    Sort-Object LocalPort |
    Format-Table LocalAddress, LocalPort, OwningProcess

SSH normally uses TCP 22 and RDP uses TCP 3389, but always allow your configured port. Use whichever firewall manager is already active on Linux—never enable UFW and firewalld together. Also check Additional Tools → Firewall in the client area.

2. Allow SSH or RDP through your OS firewall

On Ubuntu or Debian with UFW, allow your SSH port (and any needed app ports) before running ufw enable. Replace 22 with your actual SSH port. For Windows, run the rule in Administrator PowerShell and replace 3389 and 198.51.100.25 with your RDP port and your own public IP address:

Inside the VPSAllow SSH or RDP access through the firewallUbuntu / DebianBash
sudo ufw allow 22/tcp
sudo ufw status numbered
sudo ufw enable
sudo ufw status verbose
Inside the VPSAllow SSH or RDP access through the firewallWindowsPowerShell
New-NetFirewallRule -DisplayName "RDP from admin IP" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389 -RemoteAddress 198.51.100.25

See the Ubuntu UFW guide for more syntax.

3. firewalld: allow access in the correct zone

On Linux servers running firewalld, check the active zone assigned to your interface first:

Inside the VPSCheck the zone assigned to your network interfaceUbuntu / DebianBash
sudo firewall-cmd --get-active-zones

Add your SSH port to the runtime configuration first. Replace public with the active zone you found above and 22 with your actual SSH port:

Inside the VPSAdd an access rule to the runtime configurationUbuntu / DebianBash
sudo firewall-cmd --zone=public --add-port=22/tcp

Test a second SSH connection, then save the tested rule permanently in the same verified zone and port (firewall-cmd manual). The runtime rule is already active, so no reload is needed for this step:

Inside the VPSSave the access rule after testing a new connectionUbuntu / DebianBash
sudo firewall-cmd --permanent --zone=public --add-port=22/tcp

4. Windows Firewall: allow RDP and test a second session

Use the Windows PowerShell rule in Step 2 (New-NetFirewallRule), replacing the example IP and port. On any OS, always open a second SSH or RDP session to confirm your rules work before closing the first session.

5. Use Console to repair blocked remote access

If you get locked out, sign in through Console on the service page and fix the blocking rule in your OS firewall or Additional Tools → Firewall. Do not flush all rules or disable the firewall completely, and remember that guest rules cannot override our network-level port 25 policy.

Console is the rightmost control on this service toolbar. Use it to inspect the guest firewall without relying on SSH or RDP access.
Console is the rightmost control on this service toolbar. Use it to inspect the guest firewall without relying on SSH or RDP access.

Console is the rightmost control on this service toolbar. Use it to inspect the guest firewall without relying on SSH or RDP access.

Full-size image. Scroll to see the complete image.

Console is the rightmost control on this service toolbar. Use it to inspect the guest firewall without relying on SSH or RDP access.

Frequently asked questions

How can I avoid losing SSH or RDP access?

Keep Console and your current session open, check and allow your actual SSH or RDP port before enabling the firewall, and test a second login before closing your original session.

Can I enable both UFW and firewalld?

No. Running both creates conflicting firewall rules. Use only the firewall manager already active on your Linux server.