I ran the following iptables commands to allow incoming SSH and ICMP connections and block all others. sudo iptables -F INPUTsudo iptables --policy INPUT ACCEPT && sudo iptables --policy OUTPUT ACCEPT && sudo iptables --policy FORWARD ACCEPTsudo iptables -I INPUT -p tcp --dport 22 -j ACCEPTsudo iptables -I INPUT -p icmp -j ACCEPTsudo iptables -I OUTPUT -p tcp --sport 5051  -j REJECTsudo iptables -A INPUT -j REJECTThe resulting iptables listing looks like thisChain INPUT (policy ACCEPT)target     prot opt source               destination         ACCEPT     icmp --  anywhere             anywhere            ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:sshREJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachableChain FORWARD (policy ACCEPT)target     prot opt source               destination         REJECT     tcp  --  anywhere             anywhere             match-set minuteman dst,dst tcp flags:FIN,SYN,RST,ACK/SYN reject-with icmp-port-unreachableDOCKER-ISOLATION  all  --  anywhere             anywhere            DOCKER     all  --  anywhere             anywhere            ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHEDACCEPT     all  --  anywhere             anywhere            ACCEPT     all  --  anywhere             anywhere            Chain OUTPUT (policy ACCEPT)target     prot opt source               destination         REJECT     tcp  --  anywhere             anywhere             tcp spt:ita-agent reject-with icmp-port-unreachableREJECT     tcp  --  anywhere             anywhere             match-set minuteman dst,dst tcp flags:FIN,SYN,RST,ACK/SYN reject-with icmp-port-unreachableChain DOCKER (1 references)target     prot opt source               destination         Chain DOCKER-ISOLATION (1 references)target     prot opt source               destination         RETURN     all  --  anywhere             anywhere            I see that line accepting SSH comes before the one that rejects all other traffic. But I am still not able to SSH into the machine.Any clues why this is not working?
Iptables policy to accept incoming SSH and ICMP only
iptables