Stopping brute-force ssh scans the easy wayI recently stumbled over this blog entry on a nice, easy way to stop brute force ssh scans, so it's time to spread this knowledge around. If you've got an ssh daemon exposed to the Internet, you know about the brute force ssh scans and password guessing attacks. The real problem with them is the sheer volume, which creates log clutter (and system load) as they spew login failures and unknown users all over your logs. (If brute force ssh attacks give you security ulcers, get passwords that follow even basic password security rules, because the scanners pretty much only try obvious simple passwords. Anyone who gets compromised by one should be hideously embarrassed.) In theory the easy way to stop them is to block ssh access from all the networks that don't need it (even tcpwrappers will do; a few 'connection refused' and the scanners go away). Unfortunately, figuring what such places are (or aren't) can be a slog, and it can change over time, and your users can lynch you when you get it wrong. Thus the easy way to stop brute force ssh scans is to rate-limit
incoming ssh connections; this keeps the log spam down to a couple of
entries. Linux iptables can do this using the
[repeat for all of the netblocks and IPs you want know you want to accept ssh from all the time.]
(This blocks people after 3 new ssh connections within 60 seconds.
If you prefer different numbers, adjust Both lines are necessary because you can only give one of You can see the state of this ruleset in
Documentation on the Naturally, the kernel side of this has to be built for your kernel, which is yet another reason to always enable NAT et al in your kernel configuration. (I failed to do this on the system where the brute force scanners most annoy me, thereby insuring they will be annoying me for a while more yet.) (It turns out that I am late to this particular party; people have been talking about this since at least February of 2005.) Updated December 16th: corrected the (6 comments.)
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |