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 allow 22/tcp

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

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

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

Add to Favourites  Add to Favourites    Print this Article  Print this Article

Was this answer helpful?