How to Unblock SSH ...
Clear all

How to Unblock SSH and FTP Access to Specific IP in Linux  


Ganesh A
Noble Member
Joined: 4 months ago
Posts: 1170
01/04/2021 12:35 pm  

How can I actually check whether I'm being blocked by a firewall between my Linux machine and a target host? In case the firewall is blocking the connection how to do I unblock it?

Is it possible to allow and deny connections from IPs in Firewall? Or is it just the IP Tables?

Sathish Kumar
Member Moderator
Joined: 4 months ago
Posts: 1203
01/04/2021 12:37 pm  

Firewalls(most of them) can either Reject or Deny/Drop the traffic.  Reject action sends an ICMP Port/Destination Unreachable response back to the source while Drop/Deny action sends nothing back and will silently drop the connection. Which means the firewall is blocking the traffic.

Use the following syntax you can unblock an IP (the -d options deletes the rule from table):
# iptables -D INPUT -s -j DROP
# iptables -D INPUT -s -j DROP
# service iptables save

To unblock or enable SSH access, go to the remote server and run the following command:

  1. Using IPtables Firewall

    # iptables -I INPUT -s -p tcp --dport ssh -j ACCEPT            

  2. Using FirewallD

    firewall-cmd --direct --add-rule ipv4 filter INPUT 1 -m tcp --source -p tcp --dport 22 -j ACCEPT

To unblock ftp access

  1. iptables -I INPUT -s -p tcp --dport 20,21 -j ACCEPT   or

  2. firewall-cmd --direct --add-rule ipv4 filter INPUT 1 -m tcp --source -p tcp --dport 20,21 -j ACCEPT


Try it out!