News for hackers. Stuff that matters.
Re:Fail2ban security update by sneak on Thursday July 17, 2014 @04:14PM (#8049916)
Fail2ban is fundamentally a wrong answer to the problem. If you're taking the time to install such things, you should instead either be turning off password authentication (relying only on keys) or shorewall (to default deny ssh access except to authorized subnets) or both.

Waiting for multiple authentication failures to mark a host/net as "bad" is fundamentally a bad idea. Stop using passwords.

Re:Fail2ban security update by knyt on Thursday July 17, 2014 @04:17PM (#8049935)
I've used Fail2Ban even with SSH password authentication turned off. It's still helpful for preventing huge error logs full of pointless password guesses.

It's also useful for applications where you have to use passwords or where you need to allow anonymous requests but you don't want attackers using up all of your resources. VoIP (public-facing and handset-facing SIP) servers are my example of both of those situations.

Re:Fail2ban security update by justizin on Thursday July 17, 2014 @05:02PM (#8050163)
right, anyone who has undergone frequent ssh brute force attacks knows that they can create a nontrivial amount of cpu usage.
Re:Fail2ban security update by atmosx on Thursday July 17, 2014 @05:48PM (#8050403)
Practically evert open 22 port receives a huge amount of scripted attacks these days.
Re:Fail2ban security update by jqm on Thursday July 17, 2014 @06:00PM (#8050469)
Which is why a port other than 22 is pretty good practice.
Re:Fail2ban security update by rlpb on Thursday July 17, 2014 @07:46PM (#8050894)
"There's No Protection In High Ports Anymore. If Indeed There Ever Was." http://bsdly.blogspot.co.uk/2013/02/theres-no-protection-in-...
Re:Fail2ban security update by nikatwork on Thursday July 17, 2014 @08:59PM (#8051148)
Unless the majority of ssh brute force attacks iterate over every port value, using a non-standard port would still have value in reducing the volume of attacks.
Re:Fail2ban security update by jimktrains2 on Thursday July 17, 2014 @09:50PM (#8051272)
It's less protection and more just avoiding aimless attacks.

If someone's out to get you, then sure, they'll find the port.

If someone's out to just find any unlocked door, they'll just move on.

Re:Fail2ban security update by rtehfm on Thursday July 17, 2014 @06:13PM (#8050545)
Except when programs are designed for SSH to communicate on port 22. Security by obscurity is not good practice but other than that, yes, using a non standard SSH port will greatly reduce random drive by attempts.
Re:Fail2ban security update by atmosx on Friday July 18, 2014 @12:53AM (#8051728)
Just configure the localhost to route the ssh connections over a different port. Combined with ssh keys an becomes extremely convenient setup e.g.:

    ~> cat .ssh/config
    ControlMaster auto
    ControlPath /tmp/%r@%h:%p
    ControlPersist yes

    Host hostname1
     IdentityFile ~/.ssh/id_rsa
     Hostname rem.hostname1.com
     Port 2290
     user user_name
Now you can things like:

    git clone ssh://username@hostname1/home/user/Code/repot.git
or

    scp file1.tar hostname1:/home/username && sftp hostname1

Which is pretty handy :-)
Re:Fail2ban security update by tadfisher on Thursday July 17, 2014 @10:46PM (#8051427)
The proper method of dealing with programs like that is to fix them or use other programs.
Re:Fail2ban security update by feld on Saturday July 19, 2014 @04:45PM (#8058659)
I changed my mail server to listen on port 26 and now I don't get spam anymore
Re:Fail2ban security update by nrr on Saturday July 19, 2014 @05:16PM (#8058768)
I imagine you don't get much of anything with your smtpd running on port 26. (:
Re:Fail2ban security update by atmosx on Friday July 25, 2014 @02:18PM (#8086645)
LOL
Re:Fail2ban security update by feld on Tuesday July 22, 2014 @03:00PM (#8070926)
indeed!
Re:Fail2ban security update by qnaal on Thursday July 17, 2014 @05:57PM (#8050445)
"stop coming to my house Internet, I just want to stay friends"
Re:Fail2ban security update by thaumaturgy on Thursday July 17, 2014 @04:29PM (#8050018)
I'm in no danger of ssh ever being brute'd, but having logs fill up with piles of attempts is annoying and some hosts can be very persistent.

In my case, I also use it to prevent other abuse: bans for ssh abuse protect other hosted services, and fail2ban has been modified to act on other forms of abuse too (like spam).

Re:Fail2ban security update by ckoepp on Friday July 18, 2014 @07:45AM (#8052506)
I agree even though I'm not sure the problem is on the "using passwords" side. There are more fundamental problems with fail2ban & Co.

Using regular expressions on logs and triggering such massive actions like IP-based bans isn't a wise thing to do. Logs are not the trivial lines of text they were 10 years before. In reality you'd have to deal with chaotic stuff often even including user-entered data - this is why there are so many classical Big-Data programs and algorithms are joining the party here. It's very hard to write solid regular expressions on those without overseeing a tiny DoS possibility because of injection. There are numerous examples in the CVE database for exactly this when you look at fail2ban and other programs using the same scheme...

If you really need to keep your logs clean and there is no way in detecting "unusual behaviour" by filtering out all those background noise you see on SSH usually, why not use iptables with it's extensions instead? You can easily count the attempts to connect to defined ports and block any IP address reaching a threshold for a limited amount of time. This is a way more solid implementation of the same thing as IP packages are well-defined structures and there is simply no way in injecting something in the IP source field of them.

About the hardware consumption by SSH login attempts: you guys aren't honestly arguing that a cronjob-like grep of log-files and performing regular expressions on hundreds of lines is a way better to do the same, right? This is actually highly inefficient too...

For me, even plain iptables filtering isn't a nice thing. I use port-knocking to get access to my SSH services. Every server has it's unique sequence of packages to tell it to open access to SSH for a IP transmitting the right packages with the right flags and payload in the correct ordering.

I'm not saying "get rid of fail2ban", but people should know what they are doing and what problems come with those programs. The convenience has it's price...

Re:Fail2ban security update by kazinator on Thursday July 17, 2014 @06:10PM (#8050523)
In addition to the other responses:

tools like fail2ban are not only for SSH!

I also use log monitoring and banning to ban http connections to my web server (driven by scanning apache logs), as well as SMTP connections (scanning Exim's rejectlog).

The rationale "do not use password authentication" does not apply to unauthenticated HTTP and SMTP requests.

Re:Fail2ban security update by bigiain on Thursday July 17, 2014 @06:18PM (#8050567)
Fail2Ban can be configured pretty easily to do things like stopping drive-by botnet password guessing for WordPress installs. (See http://23x.net/908/securing-wordpress-using-fail2ban.html for some getting started hints.)
Re:Fail2ban security update by feld on Saturday July 19, 2014 @04:48PM (#8058668)
we do that at work. Found it to painful to make fail2ban to watch to hundreds of vhost log files so we just sniff the requests with ngrep and log them to a file fail2ban watches
Re:Fail2ban security update by viraptor on Thursday July 17, 2014 @06:43PM (#8050671)
You can do both and use denyhosts instead of fail2ban. That one doesn't even require multiple authentication failures. Known-bad hosts are blocked because enough other people blocked them: http://stats.denyhosts.net/stats.html
Re:Fail2ban security update by WestCoastJustin on Thursday July 17, 2014 @06:42PM (#8050669)
How do you manage ssh keys once deployed? From personal experience using both systems, my thinking is that once you start deploying ssh keys, in a larger user/server environment, you have a massive rats nest. There is little to no life cycle management.

Fail2ban works and should be deployed regardless of whether you are using usernames/passwords or keys. I just checked one of our bastion hosts, and there are 384 banned IPs (on a rolling 30 day basis). This info is useful, and can be fed into other systems, like edge network devices.

There is actually a good article about this @ http://www.networkworld.com/article/2164048/tech-primers/ssh...

Re:Fail2ban security update by viraptor on Thursday July 17, 2014 @06:51PM (#8050699)
That's one weird article (or maybe people really do that... I would hope they don't):

> mesh of key-based access is so dense that it is highly likely that an attack can spread to nearly all servers in an organization

Why would you ever do that? Keep the keys where the users are. There is no mesh unless you distribute the private keys and you should never do that in the first place. ssh-agent can be used if you really need to have multiple hops.

> odds are the virus will infect nearly all servers [...] including disaster recovery and backup systems that are typically also managed using such keys

Why would you store private keys to your DR/backup servers all over the place? Backup is safer if it works via pull.

There are problems with SSH key management, but the situation they describe looks like there are issues with the design in general.

(as for the keys management - there are many solutions allowing reading public keys from ldap - that solves some of the problems)

Re:Fail2ban security update by lloeki on Friday July 18, 2014 @07:50AM (#8052517)
> ssh-agent can be used if you really need to have multiple hops.

Possibly you mean, in one's ~/.ssh/config:

    Host *.trusted.hosts another.one.trusted
        ForwardAgent yes
The restriction with Host is that otherwise an untrusted host (or someone having compromised your remote account) could use your agent forwarding socket to identify as you.
Re:Fail2ban security update by pjc50 on Friday July 18, 2014 @08:35AM (#8052652)
Keep the keys where the users are

That's in the user's home directory. Which is stored on the network ...

The other antipattern is defining a passphraseless key for root@serverA and putting that in authorized_keys on serverB. This is trememdously useful but insecure.

Re:Fail2ban security update by sneak on Thursday July 17, 2014 @07:18PM (#8050794)
> How do you manage ssh keys once deployed? From personal experience using both systems, my thinking is that once you start deploying ssh keys, in a larger user/server environment, you have a massive rats nest. There is little to no life cycle management.

Same way you manage any other keys - configuration management software. "Keys are hard to manage" is not a valid argument against "you should not be using passwords or fail2ban".

Re:Fail2ban security update by pyre on Friday July 18, 2014 @01:28AM (#8051807)
Maybe I'm missing something, but where does fail2ban come in on the "keys vs. passwords" debate? Do I become more vulnerable if I run fail2ban on a keys-only ssh setup? If not, then why is the argument "don't use passwords or fail2ban" rather than just "fail2ban doesn't provide adequate protection for allowing passwords on ssh?"
Re:Fail2ban security update by Spooky23 on Thursday July 17, 2014 @10:30PM (#8051375)
There are many methods.

You can have batch processes push them out periodically.

You can put public keys in LDAP

You can configure SSH to use Kerberos.

Re:Fail2ban security update by tacticus on Thursday July 17, 2014 @08:45PM (#8051112)
You can put your pub keys into ldap and get sshd to query that when you try and connect.
Re:Fail2ban security update by zorbo on Thursday July 17, 2014 @04:57PM (#8050147)
It is possible to use brute-force via timing attacks to determine whether accounts exists on hosts, and then either focus different attacks on those accounts or spam them.

It is amazing how much this needs to be repeated, but security is not an absolute. Fail2ban adds another layer of security, thus it is a good thing.

Re:Fail2ban security update by stonogo on Thursday July 17, 2014 @07:30PM (#8050844)
You're making an invalid assumption; specifically, that fail2ban is only useful to protect ssh.
Re:Fail2ban security update by thomaslutz on Thursday July 17, 2014 @04:15PM (#8049927)
Why can't I use key-based auth and fail2ban as well? E.g. to prevent DDoSing. Fail2Ban does more than just monitor SSH.
Re:Fail2ban security update by atmosx on Thursday July 17, 2014 @05:47PM (#8050389)
Relying only on keys is not practical in many situations where you want to login from a different computers.
Re:Fail2ban security update by houk on Thursday July 17, 2014 @06:12PM (#8050540)
that's assuming your use case for fail2ban is only blocking failed ssh login attempts. it's pretty handy for blocking malware scanners, x number of failed logins to wordpress/drupal/etc, and all that jazz.
Re:Fail2ban security update by kbar13 on Thursday July 17, 2014 @04:37PM (#8050070)
I'm not sure why this comment is getting downvoted, especially since the users who replied to this comment correctly understand that Fail2Ban is a log prettifier and use it as intended.