Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 was wondering how I could deny all SSH logins from any IP but mine? This would be using IPTables.

share|improve this question
    
@Paul I honeslty didnt know where to start... I am not too fond of IPTables – user1307079 Mar 6 '13 at 0:46

There are multiple ways to do this using iptables - From the command line:

/sbin/iptables -I INPUT -s MY.IP -p tcp --dport 22 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22 -j DROP

You can do a similar thing leaving out the /sbin/iptables, adding it near the top of /etc/sysconfig/iptables and then doing a restart.

If you want to steer clear of IPTables altogether you can simply modify the SSHD config by adding the following line to the end of /etc/ssh/ssd_config (and then restarting sshd)

AllowUsers  myuser@my.ip.address

(If there is more then one user you can use the form AllowUsers myuser@my.ip myuser2@myip myuser3@my.ip )

share|improve this answer

Looks like you need to configure iptables as @davidgo has mentioned. Adding:

-A RH-Firewall-1-INPUT -s 192.168.1.1 -m state --state NEW -p tcp --dport 22 -j ACCEPT

to your /sbin/iptables might work (change the ip to the desired address).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .