Re: SSHD: Limit login attempt rate



On Thu, 24 Jul 2008, in the Usenet newsgroup comp.os.linux.networking, in
article <103d250f-85a7-4240-aa96-81c1a8f2a85d@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
bmearns wrote:

NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.

I'm running an sshd on Fedora 8, and have recently been getting
swamped with people trying to log in (i.e., break in). It's configured
to only allow three authentication attempts per connection, but they
just keep reconnecting: probably some script kiddies with port
sniffers and password testers.

This question comes up constantly, and has been answered many times.

Are you a world traveler, or do you have users authorized to log into
your system from every IP address in the world? You'll find you will
waste less CPU cycles by configuring your firewall to only allow
connections to your SSH server from IP addresses you actually expect
may have a legitimate reason to connect. For me, that means allowing
just 1536 IP addresses (a /22 and two /24s) out of the 2676890800 IPv4
addresses in current use in the entire world.

What you are seeing is skript kiddiez and bots - and one thing they are
sure of is that you must only run an SSH server on port 22. A very
common solution that defeats this knowledge is to move your server to
a "high" port. Your Linux distribution comes with a network exploration
tool called 'nmap' - look at the documentation that comes with this
tool, and locate a file named 'nmap-services' which will show port
numbers to avoid. Before you think "SECURITY THROUGH OBSCURITY!"
remember that moving the server location in no way changes the
authentication mechanisms you have in place - you still need a valid
username and authentication token to get in.

Seeing as how you are posting from a search engine, you might also
try searching for 'port knocking' - a technique that requires a valid
user to first attempt to connect to some unusual port number which is
closed on your end. The port knocker daemon is listening for such
connection attempts, and can then open what-ever port you have hidden
the SSH server to that address ONLY, and only for a short time needed
to get the connection running. This is useful in cases where your
remote system is otherwise restricted from making connections to
non-standard ports/services. Again, this isn't 'Security Through
Obscurity' because you still require the authentication mechanism
as above.

For example, if a particular address tries and fails three times to
authenticate, that address is blocked for three hours, or something
similar?

There are a number of such tools available - everything from fail2ban
to PortSentry and others. While blocking for a "short time" such as
three hours is better than inserting a permanent block, it is still a
good way to shoot yourself in the wobbly bits - Self Denial Of Service'
is far from unknown.

Another technique is available in the iptables firewall - rate limits.
See http://www.netfilter.org/documentation/HOWTO/ for a number of
documents that discuss the technique and rules.

Old guy
.



Relevant Pages

  • Re: Is it possible to require both a certificate and a Kerberos password for authentication?
    ... >> other SSH server? ... >> technique on one port, and a> secondary technique on another port ... OpenSSH does not support requiring multiple client authentication ...
    (comp.security.ssh)
  • Re: Using Putty for the SSH tunnel AND the telnet program
    ... Putty makes a TCP connection to port 22 on the SSH server. ...
    (comp.security.ssh)
  • Re: ssh_init: Network error: Connection refused
    ... > Is that the SSH server or is there a daemon missing? ... but it may not be the daemon -- they could be just left ... try connecting to port 22 from the same machine (e.g. ... otherwise you'd get a timeout instead of "connection refused"). ...
    (comp.security.ssh)
  • Re: port forwarding
    ... This indicates that the SSH server declined the direct-tcpip channel the ... client requested in response to the connection to the locally forwarded ... port. ...
    (comp.security.ssh)
  • Re: OWA Question
    ... I'd just hit http://mail.company.com and see if it puts up the dialog ... box for authentication. ... connection though as your internal resolution is working okay. ... that your mail is coming via port 25, port 80 or 443 should be open ...
    (microsoft.public.exchange.admin)