Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 servers and want to be able to connect via SSH from server A to B and vice versa. What Iptables rules should I set on both machines to make this possible ? SSH is runnning on default port 22

share|improve this question
possible duplicate of iptables Ubuntu VPS SSH rule – mailq Oct 2 '11 at 20:20

You should add the next rule to both hosts. You can define source and destination ip address (-d) in case you only want to connect from this hosts in a bilateral connection. In any case you should take a look to the iptables documentation

iptables -A INPUT -p tcp --dport 22 --m state --state NEW,ESTABLISHED -j ACCEPT

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.