Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was wondering how I could deny all SSH logins from any IP but mine? This would be using IPTables.

share|improve this question
    
What have you tried so far? –  Paul Mar 6 '13 at 0:45
    
@Paul I honeslty didnt know where to start... I am not too fond of IPTables –  user1307079 Mar 6 '13 at 0:46

2 Answers 2

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

Your Answer

 
discard

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.