11 ms·
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 au
by sneak 12y ago
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.
- thomaslutz 12y agoWhy can't I use key-based auth and fail2ban as well? E.g. to prevent DDoSing. Fail2Ban does more than just monitor SSH.
- knyt 12y agoI'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.
- justizin 12y agoright, anyone who has undergone frequent ssh brute force attacks knows that they can create a nontrivial amount of cpu usage.
- atmosx 12y agoPractically evert open 22 port receives a huge amount of scripted attacks these days.
- qnaal 12y ago"stop coming to my house Internet, I just want to stay friends"
- jqm 12y agoWhich is why a port other than 22 is pretty good practice.
- rtehfm 12y agoExcept 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.
- tadfisher 12y agoThe proper method of dealing with programs like that is to fix them or use other programs.
- atmosx 12y agoJust 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 :-)
- rlpb 12y ago"There's No Protection In High Ports Anymore. If Indeed There Ever Was." http://bsdly.blogspot.co.uk/2013/02/theres-no-protection-in-high-ports.html http://bsdly.blogspot.co.uk/2013/02/theres-no-protection-in-...
- nikatwork 12y agoUnless 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.
- jimktrains2 12y ago
- thaumaturgy 12y agoI'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).
- kbar13 12y agoI'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.
- zorbo 12y agoIt 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.
- atmosx 12y agoRelying only on keys is not practical in many situations where you want to login from a different computers.
- kazinator 12y agoIn 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.
- bigiain 12y agoFail2Ban 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 http://23x.net/908/securing-wordpress-using-fail2ban.html for some getting started hints.)
- feld 12y agowe 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
- houk 12y agothat'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.
- WestCoastJustin 12y agoHow 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-key-mismanagement-and-how-to-solve-it.html http://www.networkworld.com/article/2164048/tech-primers/ssh...
- viraptor 12y agoThat'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)
- lloeki 12y ago> 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.
- pjc50 12y ago
- viraptor 12y agoYou 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 http://stats.denyhosts.net/stats.html
- stonogo 12y agoYou're making an invalid assumption; specifically, that fail2ban is only useful to protect ssh.
- ckoepp 12y agoI 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...