Portal Home > Knowledgebase > Connection Problems > Commands to allow SSH access in common firewalls

Commands to allow SSH access in common firewalls

If you've recently installed a firewall in your server and have suddenly lost access or after a reboot, you can use the console we provide in the client area to log in and execute the following commands to allow SSH access on the default port. You can use the same actions to allow a different SSH port you've configured in your SSH server config, changing 22 to the port you've selected.

UFW:
ufw allow 22/tcp

CSF: 
Edit /etc/csf/csf.conf with your preferred text editor.
Add port 22 to TCP_IN, following the same formatting already visible in the config file for TCP_IN
Save the file, exit the text editor
Execute: csf -r

Firewalld:
firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --reload

iptables:
iptables -I INPUT -m tcp -p tcp --dport 22 -j ACCEPT

nft (replace "inet" with your nft table name):
nft add rule inet filter input tcp dport 22 ct state new tcp flags \& \(syn \| ack\) == syn counter accept

Was this answer helpful?
My VPS shows offline and I cannot start it. What to do?

If your VPS is offline and you cannot start it, please use My VPS Is Down option in Submit Ticket...

How to restore my SSH access?

If you are getting timeouts trying to connect to your VPS using SSH but your VPS IP is pinging...

I have installed WHM/cPanel, my root password doesn't work sometimes.

WHM/cPanel has CPHulk and sometimes this can cause your root password not to work. In order to...

I have cPanel. Why can't I login via SSH or WHM?

This is most likely cPHulk at work, which works to protect your cPanel installation from being...

My Port XXX is closed. Can you open it?

The following ports are blocked/filtered by default, and to preserve network quality, cannot be...