Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to lock down ssh. Before I apply anything that requires me to go in and manually have to unhook things, I wanna check I have the rules sorted out correctly.
Effectively what I am after is a password cap of 3~5 attempts a minute, preferably one that then locks the connection for 15~30 minutes and logs the denial in a log. it's not the most straight forward passwords so I can sometimes make several mistakes, so I don't want a perm-block enforced and having to get deny.host cleared so I can re-access the server.
I have written the script below so that I don't inadvertily lock myself out of the server, generally I am running this on VPSs first so I can rescue them, but will want to apply it to the main server itself.
Code:
iptables -A RH-Firewall-1-INPUT -p tcp --dport 22 -j DROP
iptables -I RH-Firewall-1-INPUT -p tcp --dport 22 -m state --state NEW -m limit --limit 1/minute --limit-burst 5 -j ACCEPT
So is their anything I need to change or will this work, if this does block an IP how long would it be blocked for? Thanks for the help.
P.S. going to bed now so don't worry if I don't respond to this too quickly =P.
Last edited by r3sistance; 01-25-2009 at 06:53 PM.
I am trying to lock down ssh. Before I apply anything that requires me to go in and manually have to unhook things, I wanna check I have the rules sorted out correctly.
Effectively what I am after is a password cap of 3~5 attempts a minute, preferably one that then locks the connection for 15~30 minutes and logs the denial in a log. it's not the most straight forward passwords so I can sometimes make several mistakes, so I don't want a perm-block enforced and having to get deny.host cleared so I can re-access the server.
I have written the script below so that I don't inadvertily lock myself out of the server, generally I am running this on VPSs first so I can rescue them, but will want to apply it to the main server itself.
Code:
iptables -A RH-Firewall-1-INPUT -p tcp --dport 22 -j DROP
iptables -I RH-Firewall-1-INPUT -p tcp --dport 22 -m state --state NEW -m limit --limit 1/minute --limit-burst 5 -j ACCEPT
So is their anything I need to change or will this work, if this does block an IP how long would it be blocked for? Thanks for the help.
P.S. going to bed now so don't worry if I don't respond to this too quickly =P.
Your rules create a denial-of-service vulnerability. I would basically just need to send a couple TCP packets to your box every now and then and neither you or anyone else will be able to connect. I suggest you take some time to search the forum for threads in which people have done this sort of thing already - I know for a fact that there are several. Learning from tried and tested methods instead of trying to come up with stuff from scratch will save you a lot of headaches.
Thanks Repo, I'll look over that, I take it that's meant to be run as a script. Sounds simple to just adjust seconds to 900 (or I am guessing minutes to 15) and hitcount to 5 and I think that fits what I am after?
CaptainInsane, I don't know much about fail2ban but have heard of it in the past, sounds like it perm blocks ip, which because of the passwords I use, isn't a good idea for me (not uncommon to type it in wrong let's say). Last thing I want to do is perm block my own ip out from the server. I'd rather have a time limited block that I can control.
Last edited by r3sistance; 01-26-2009 at 11:09 AM.
Thanks Repo, I'll look over that, I take it that's meant to be run as a script. Sounds simple to just adjust seconds to 900 (or I am guessing minutes to 15) and hitcount to 5 and I think that fits what I am after?
CaptainInsane, I don't know much about fail2ban but have heard of it in the past, sounds like it perm blocks ip, which because of the passwords I use, isn't a good idea for me (not uncommon to type it in wrong let's say). Last thing I want to do is perm block my own ip out from the server. I'd rather have a time limited block that I can control.
Most bruteforce tools such as fail2ban or Denyhosts have whitelists of IPs that the tool isn't supposed to ban.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.