The Optimum Attack Rate For SSH Bruteforce? Once Every Ten Seconds 167
badger.foo writes "Remember the glacially slow Hail Mary Cloud SSH bruteforcers? They're doing speedup tweaks and are preparing a comeback, some preliminary data reported by Peter Hansteen appear to indicate. The optimum rate of connections seems to be 1 per ten seconds, smack in the middle of the 'probably human' interval."
Passwords are for philistines (Score:5, Informative)
Re:Passwords are for philistines (Score:4, Insightful)
Re:Passwords are for philistines (Score:5, Insightful)
Re:Passwords are for philistines (Score:5, Insightful)
Once someone has your key, it's no more secure than your password.
Whether the token is something you know, something you are, or something you have, it *all* becomes useless once someone else has it. That's not really the issue here. The issue is brute-force attacks on SSH, and using a key makes them significantly more difficult than passwords.
Stealing someone's key/password is not a brute-force attack.
Re:Passwords are for philistines (Score:4, Funny)
Re: (Score:2)
Re: (Score:2)
Someone cannot have something you are without you being aware of it.
Re:Passwords are for philistines (Score:5, Insightful)
That's nice in theory and all, but it depends on what that "something you are" is. Essentially we're talking about biometrics, so what are we measuring? Is it a thumbprint scan? Those have been defeated in the past by taking a thumbprint and replicating it by some means. Is it a DNA scan? Then they might just need to get ahold of your DNA.
Really, the "something you are" is still "something you have", but you "have" it attached to your body. That doesn't necessarily mean it can't be stolen or replicated somehow. Similarly, the "something you know" can also be considered to be "something you have", but you "have" it in your mind. In some circumstances, it can still be figured out or retrieved, or you might be tricked into providing it.
Real security isn't quite as simple as you make it sound.
Just like farm gun storage (Score:2)
Biometrics or whatever don't matter, the important thing is to make sure an attacker can't get everything they need to get in from one place. A key on a USB stick or the local machines disk and the passphrase/password in your head is not one place. If an attacker aims to trick you into providing access then they have have to trick you twice, or steal and trick you.
Re: (Score:2)
Really, the "something you are" is still "something you have", but you "have" it attached to your body.
Not necessarily. Something you are is nine-times. The gard at the entrance knows you as nine-times. For hime you _are_ nine-times. Maybe you get fired from work and your badge (something you have) is revoked and your system password (something you know) is removed. But they forget to notify the guard and the next day you manage to walk in as usual, because he knows you. Of course the opposite situation is possible too: the boss throws you out and tells the guard not to let you in, even though your cards pas
Re: (Score:2)
Re: (Score:3)
If the computer with the key is compromised, the game is over. The password can be slurped, the key snarfed, and even the session hijacked.
It is all about limiting exposure. Going to public keys closes a potential common method of access, brute force guessing.
No security method is 100%, but in a lot of cases, something is better than nothing, and having at least root locked out from password guessing is a must for Internet facing systems.
Re: (Score:2)
Re: (Score:2)
Re:Passwords are for philistines (Score:4, Interesting)
RSA key/pair is something you have... you still need something you are, and something you know... Once someone has your key, it's no more secure than your password. A trojan can read local files, just as easily, if not more so than snoop for a password.
When you send bits out, everything in those bits is "something you know".
You don't need to have the keyfob, you just need to know what it will output at any given time, or what a prior output was (as long as you use it within the time window for which it is valid - typically 30 seconds to 2 minutes). Yes, it's mathematically hard to get the key by brute forcing, but it's not impossible. When you log in with one of those, you're not proving that you have the thing, you're proving that you know what it output at a given time.
Imagine if PS4 games had built in RSA shits right onto game discs. (Or the Vita game cards if you can't imagine a thing battery, cpu, and display on a disc.)
Touch an area on the surface of the game disc (or card) and get a password on a little display. You have to put that password in within X time to access the game. This isn't secure because even if Bob holds onto the disc physically, Alica can call him up and ask him to read the code.
Sony wants the disc to be in Bob's physical possession (and no one else's) at any given time, but they cannot rely on this type of security to ensure that. For all they know Bob is visiting Alice and brought his new game over.
Re: (Score:2)
Are you thinking of RSA SecurID? That is something quite different.
If you want to log in to my SSH server, then in practice you need a private counterpart to a public key which you have added to your authorized_keys file.
Re: (Score:2)
Re: (Score:2)
Sorry, but fail. 2-factor only works when both factors are independent. That is not the case here, as they are always used together. About the only way to compromise the RSA key is to compromise the SSH source host. But as soon as you have that, you also have the password on the first login, hence both are not independent.
Re: (Score:3)
soon computers will pass the tests better than humans.
there are two types of tests:
- ones with a rather small set of human-made puzzles, computers can just learn them one time
- ones which are generated by computers. Those can be solved by computers, too.
The most ridiculous ones are simple math problems in the html-text.
the average case is some distorted text, which will soon be no problem for computers anymore, as OCR software is getting better.
Re: (Score:3)
I've been passing as human for years, you insensitive clod!
Re: (Score:3)
Re: (Score:2)
That's an interesting idea.
At that point you have to apply a band-pass filter. If a computer can solve a problem more easily than a human, then superhuman performance is a sign of non-humanness.
Re: (Score:2)
Re:Passwords are for philistines (Score:5, Interesting)
Anyone see these guys on a port other than 22?
Re:Passwords are for philistines (Score:4, Informative)
[1] For example, if you already have to expose https to the world you could have a web app that triggers the opening of ssh access for the web client's current IP.
Re:Passwords are for philistines (Score:5, Interesting)
Re: (Score:2)
I'm running fail2ban myself. 3 wrong guesses and get banned for 30 minutes. Not really an issue for me, I did leave pasword auth on for users, but not root you need a key to ssh to root. None of my users can su either, and sudo isn't even installed.
Re: (Score:2)
This way externals cannot access the ssh server if the firewall service is disabled or has no rules.
Re:Passwords are for philistines (Score:5, Informative)
Good point. My standard setup is to move SSHD to a non-standard port, and to turn off PasswordAuthentication completely in favour of RSA key-pairs.
Just checking my SSHD logs, it looks like I've had exactly one rejected attempt on a busy public-facing web server (which may in fact have been me, connecting from a machine that I hadn't set up a key for) in the past month... so in my experience, no, they're not trying too hard off of port 22.
Re: (Score:3)
This is probably not a solution if you have a bunch of users, but for a home machine it's not that hard to create a password that will never be guessed by some bot trying one dictionary word every 10 seconds.
Re:Passwords are for philistines (Score:5, Informative)
I double that up. sshd to a nonstandard port, and firewall rules to only allow access in from very specific IPs and networks.
You really shouldn't be able to ssh in from just anywhere. Even if that means throwing a copy of OpenVPN up at a static location, to ssh to the second.
I can get to most of my stuff directly from home. At a hotel, airport, or coffee shop, I am on a hostile network, and shouldn't even be able to see that the port is open.
But, most people scanning for machines with SSH on them to hit are blindly scanning port 22. It's people interested in your specific network will scan every port on every machine. Someone determined to hit your machine specifically will try every trick they can, and having SSH on port 2222, 9222, or 64222 won't help, if you have a weak password or an exploitable version.
Re: (Score:3)
And it is rather easy to ask nmap to do a simple sneaky-ish scan of a machine looking for SSH, and the pound away at that port.
Re: (Score:2)
Re: (Score:2)
Anyone see these guys on a port other than 22?
+1. Moving to a different service port dropped my failed login attempt logs down to nothing (at least, for now). Prior to that, my logs still weren't too big because I block IPs after #MAX_ATTEMPTS within a 24 hour window. However, the attempts were coming in at a rate of 10 minutes apart. Still, they got blocked. It's just that the hacking community seems to be well aware of trying to keep the number of attempts / unit time down to avoid detection.
Re: (Score:3)
I put my sshd on port [redacted] instead of 22 and, looking through logs now, I see no attempts at all for the last year.
Only two attempts in the past 2 years total.
They're not brute forcing SSH logins by finding SSH servers through fingerprinting yet. They're still only using conventional ports.
Re: (Score:2)
I haven't seen anyone mention Fail2ban or any other automatic firewall block rule generation script yet. The concept is flawed in that attackers can spoof addresses and manipulate your firewall, but the execution gets around that by blocking for only a limited time and hoping the attackers go after somebody else (and that somebody that was locked out by making a mistake with their passphrase a few times can try again later).
Re: (Score:3)
I'd also recommend changing the ssh listener port to something else, to keep the secure.log a little cleaner and easier to spot possible issues in.
443 is a fun one, few if any of the ssh bots even consider that one.
Re: (Score:3)
443 is a fun one, few if any of the ssh bots even consider that one.
The other advantage to 443 is that pretty much no ISP/WiFi provider/whatever will block access to that port, and since they expect to see encrypted traffic, they probably won't mess with the connection at all.
Re: (Score:3)
Meh, just add proper rules to iptables and you will be fine:
http://www.ducea.com/2006/06/28/using-iptables-to-block-brute-force-attacks/ [ducea.com]
sshguard is pretty good too:
http://www.sshguard.net/ [sshguard.net]
Re: (Score:2)
Cool, so once the hackers compromise one of your computers they can get to all of them.
Nice.
set ban interval to 11 seconds. (Score:2)
Re: (Score:3)
Re: (Score:3)
Re: (Score:2)
What would be interesting is that if someone tries to log in as root with a password (as opposed to using a public key), rather than outright deny access, just make sure all access is denied from that IP or IP range, even if a future attempt at logging on would have normally been successful. This keeps the attacker busy thinking they can gain something.
Or, if someone is really clever, spawn a fake shell which drops to a prompt, then 1-2 seconds later, have it look like it got logged out.
Something like that
Re: (Score:3)
Which is exactly what denyhosts and fail2ban do.
On failure, echo $IP:ALL >>
Re: (Score:2)
Re: (Score:2)
Exactly. If an attacker is running their stuff on some botnet clients, and gets reports that machines on a network all are accessible, it will waste their time and resources in having to vet each and every machine that reported a successful login.
It isn't a true honeypot because the machines are not giving much of an environment for an intruder to play around in, but more of a way to fool the brute forcing scripts in giving them a bunch of false positives.
Isn't that useless? (Score:3)
I'm going to guess it was a dictionary attack because otherwise it is even dumber.
That's 6 attempts per minute.
360 per hour
8640 per day
60,480 per week
3,144,960 per year.
So unless you're allowing usernames such as "root" or "admin" or "administrator" AND using dictionary passwords wouldn't this fail? And be obvious in the logs?
Re: (Score:2)
Re: (Score:3, Funny)
So unless you're allowing usernames such as "root" or "admin" or "administrator" AND using dictionary passwords wouldn't this fail? And be obvious in the logs?
You're thinking... this makes you a bad reference model for the average user.
Re: (Score:2, Interesting)
So unless you're allowing usernames such as "root" or "admin" or "administrator" AND using dictionary passwords wouldn't this fail? And be obvious in the logs?
Yes, it would be obvious in the logs. However, most of the common hacks are now scripted and distributed. They'll use a dictionary attack that is spread over some number (dozens or more) of distinct botnet systems, making it very inconvenient for you the admin to try to block all those addresses.
Although of course as you point out, it should fail if they are going for root or equivalent. That said from my experience the botnets usually seem to do a white pages type list of common usernames and then
But it still would not work. (Score:4, Informative)
Who cares about blocking them? They're not getting in anyway. Blocking is just additional work that may cause problems.
That's the reason that they're not going to get in. They're using usernames that don't exist (unless the sysadmin is an idiot in which case you have the regular idiot problems and it's probably been cracked already through one of those).
If you're using JUST first names or last names as usernames then you have a bigger problem.
Instead use something like one of the following:
FIrstnameLastname
Firstname.Lastname
FirstnameMiddleinitialLastname
You should be able to easily distinguish the potential threats from the random script-kiddies. That being a REAL username on your system with hundreds of login attempts.
And then you deal with that issue by changing the username. Then investigate how that username leaked.
Re: (Score:3)
That's the reason that they're not going to get in. They're using usernames that don't exist (unless the sysadmin is an idiot in which case you have the regular idiot problems and it's probably been cracked already through one of those).
Do you have your system set up so that email names are not user names?
Let me try to illustrate that. (Long post) (Score:4, Interesting)
At home? Yes.
I think I seen where you're going with that and I don't think you understand. Collecting email login names is easy.
But being able to login to an outward-facing server (email or ftp or ssh or whatever) should be limited to a certain amount of failed logins (no matter from which IP address) per time period.
The crackers would have to go through an ADDITIONAL step to try to match email login names with ssh login names and an ADDITIONAL ADDITIONAL step to match that name to a different type of server (such as ssh).
Let me see if I can illustrate this.
1. Attacking ssh on server A.B.C.D with username aaron - if there's any chance that the cracker can do it then the sysadmin failed. Even more so with "root" or "admin" or such.
2. Collecting username aaron.aaronson via email spammer and then trying to attack ssh on server mail.example.com - more work for the cracker than scenario #1 but still the same as #1. If there is any chance that the cracker can succeed then the sysadmin has failed. SSH should only be allowed on the mail server from the inside interface.
3. Collecting username aaron.aaronson via email spammer and then trying to attack ssh on servers in the block A.B.C.D through A.B.C.Z (and one of those is your SSH server). And the cracker is using multiple machines to make multiple attempts (one per machine) within time period X. - Again, if it works then the sysadmin has failed. Too many attempts in time period X should lock out the account for a set number of minutes. No matter how many IP addresses are involved.
-continued-
And that depends upon aaron.aaronson being a LEGITIMATE USERNAME ON THAT SYSTEM. Once the sysadmin sees that attack in the logs then the logins to that should be changed (ssh.aaron.aaronson or such) to break that attack if they were not already such. Or change them AGAIN (aaron.aaronson.ssh) and be aware that something leaked somewhere.
4. See #3 except the logins are from multiple machines but only 1 login attempt in time period X so it never triggers the account lockout. Again, change the login names (ssh.aaron.aaronson) to break that attack (and did they leak?).
In summary, getting your system cracked via SSH means that your sysadmin failed so many times.
Re: (Score:2)
And that depends upon aaron.aaronson being a LEGITIMATE USERNAME ON THAT SYSTEM. Once the sysadmin sees that attack in the logs then the logins to that should be changed (ssh.aaron.aaronson or such) to break that attack if they were not already such. Or change them AGAIN (aaron.aaronson.ssh) and be aware that something leaked somewhere.
But you are being reactive. Wouldn't it be better to have the ssh user name different from the email name, and really different, so that it is difficult to deduce one from th
Re: (Score:2)
Being completely non-related to your login ID is okay. I won't hurt anything by having it like that.
But it also won't add any additional security if you follow the other steps I've outlined.
It all comes down to the cracker being able to match (pretty much in order):
1. your SSH server
AND
2. legit username on that server
AND
3. match
Re: (Score:2)
I had that once - handed over a machine and then had to rush in to reinstall the hacked mess on night a couple of years later. The problems were:
Everybody with an email account had shell access.
Usernames were common first names.
One user had a password of "coffee".
A dire mistake or deliberate action was made with "chmod" giving all users full read, write and execute access to nearly everything on the system. Areas
Re: (Score:3)
That's 6 attempts per minute.
per zombie in the botnet. Each zombie IP gets banned individually, and the slow attack attempts prevents a DDoS.
Key AND Password (Score:5, Interesting)
So what I've never understood is why it's not possible (as far as I know) for a server to require BOTH a key AND a password. Sure, I can put a password on my key, but that isn't the same at all. Is this possible yet?
Re: (Score:2)
Re: (Score:2)
maybe with pam.
at least you can for example use password AND one-time-password with pam, which applies for ssh, too.
with OTP its more often used as password replacement (login from places where you do not trust the computer), but you can configure it as two-factor auth as well.
Re: (Score:3)
Indeed.
Google Authenticator (which is an implementation of TOTP, and doesn't send anything back to Google itself) can tie in with SSH/PAM [google.com] quite easily.
Re:Key AND Password (Score:4, Interesting)
yeah, or i once had a sshd with https://en.wikipedia.org/wiki/OPIE_Authentication_System [wikipedia.org] running. Nice thing, you generate a bunch of passwords and print it. Then you can login from everywhere without looking out for keyloggers.
Re: (Score:3)
Maybe even going back to the age-old S/KEY or OPIE protocol that has been part of BSD for 20+ years? This has fallen into disuse because it was mainly designed to foil packet sniffers, but might be a good way of doing things. Maybe modify the algorithm a little bit so it uses a modern hash, and perhaps add a random 4-5 digit number somewhere in addition to dictionary chosen words. That way, trying to brute force a pass phrase that will easily be more than 20+ characters will be almost impossible, especia
Re: (Score:2)
Re: (Score:3)
I use Mobile OTP (http://motp.sourceforge.net/) for two-factor auth at work. Once I figured out the PAM side of things, it was quite straight-forward. I installed it on my server at home as well, but I'm a little more relaxed about it -- I allow ssh from a few "trusted" boxes via ssh-keys, otherwise it requires password+OTP token authentication. Now, I just have to worry about keeping those "trusted" boxes safe. (I do have a password on the ssh keys, but wonder if I have a long-running login session wit
Re: (Score:2)
Non-Open-SSH has been able to require multiple authentication stages for some time now. Every now and then someone updates a patch for OpenSSH to do the same [mindrot.org].
Re: (Score:2)
Why would you want that? If you fear somebody else getting hold of your key, put a password on it; if you fear your key is too short, make it longer.
Re:Key AND Password (Score:4, Interesting)
There's no way for a server admin to require a passworded key for login.
The authorized keys file can specify a program (Score:2)
Perhaps that program could be "login" or something similar. Also, that give you the ability to use different command and different behaviors on a key-by-key basis for the account.
Re: (Score:2)
Or never... (Score:5, Informative)
Hence their most optimal rate for my system would be never, because they won't get in that way. Not that my system is impenetrable - I'm sure an intelligent hacker could compromise it - but they will never get in trying to ssh in as root.
If they're doing white pages username + dictionary password - or white pages username + blank password (I've seen both, from botnet attacks), they still won't get in on my system as none of the common user names are used there.
I have a portknocking setup (Score:5, Interesting)
I have a portknocking setup. All your packets bounce when you touch my port 22 until you have touched a "magic sequence" of port numbers first. That sequence can be cryptographically strong, time-dependent, etc. but even a simple one-port knock is enough to stop all this random SSH spam and has been for years.
And if you do "get lucky" and find the right ports and then detect that port 22 is open and then start a brute-force on that? Public-key-only authentication and no root logins allowed.
Impact on me? Another line in a shell script that I use to connect (and hell, even Android has free port-knocking apps, not to mention them being standard-enough to be in Ubuntu/Debian). Impact on server? Greatly reduced number of fake connections bouncing off iptables and a tiny little daemon that does nothing but listen on the ports I need (and can ONLY open the SSH port even if compromised). Impact on brute-forcers? They might as well give up and go home.
Even those remote companies that we do allow to port-forward direct to their device on my work network (e.g. telecoms providers, etc.) understand it and "knock" before they come in (which tells us exactly when they are about to log in), while everyone else in the world sees closed ports.
Why everyone doesn't use it, I have no idea. Even our VPN users have an automated script that just knocks to open the VPN ports (and only the VPN ports) before they connect. Transparent to them, invisible to everyone else, no different if "compromised".
Re: (Score:2, Interesting)
Why go through all that just to leave your SSH server on port 22?
Details? (Score:2)
Is there a package that includes this functionality or is it all custom done?
Re:Details? (Score:5, Informative)
knockd on Linux. Apt-get should find it for you. It will execute a specified shell script when it receives a specified knock (default one is specified). That shell script can be passed the IP that knocked (so you can include it in an iptables opening within the script).
There are also implementations for Windows, should you need that.
Re: (Score:2)
Re: (Score:2)
TCP port numbers are unencrypted so a serious attacker will be able to find out your sequence anyway. All you're doing is wasting your own time by making legitimate connections take longer.
Re: (Score:3)
There are cryptographically secure versions. But you've missed the point.
This stops random port-spam, random brute-force attacks, and casual access. If you want something secure, you should SECURE it (e.g. by restricting access to the bare minimum necessary and provide only public-key authentication ONLY). You can do that AND add port-knocking, if you want.
But the spam on port 22 on an unsecured machine will flood your logs the second you put it on the net. Port-knocking stops that without having to tou
Re: (Score:2)
Question though: how is it fundamentally different from simply having a slightly strongly stronger public-key-only authentication? Just the fact that that sshd doesn't get involved?
Re: (Score:3)
All your packets bounce when you touch my port 22 until you have touched a "magic sequence" of port numbers first
Using the old "ex-wife" model of security, eh?
Re: (Score:2)
Just curious, is there a reason you don't require both key pairs AND a password?
Re: (Score:2)
Yeah, just wait until the sshd zero day and associated worm.
Or don't wait and try combing through your log with all the automated attacks on wide-open port 22s.
Re: (Score:2)
Funny, I was tweakin' my firewall this morning (Score:3)
iptables with the recent module...ssh brute force attacks a thing of the past. Actually, same with RDP and just about any other service you can identify via iptables.
Rate limit those suckers to something useful ( for ssh, I configured 2 attempts in 5 minutes, everything else is dropped ), call it done.
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --set
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --update --seconds 300 --hitcount 3 -j DROP
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -j ACCEPT
( Disclaimer: the above is from memory. I am positive there are better ways and more things you can do with it )
Re:Funny, I was tweakin' my firewall this morning (Score:5, Insightful)
So how much time to break a strong password? (Score:2)
1 attempt per 10 seconds, so 360 attempts per hour, 8640 per 24 hours, 3,153,600 per year or 31 million passwords per 10 years.
Well, if your password is not in some rainbow table and it's at least moderately strong, then you should be fine.
Re: (Score:2)
rainbow-tables are not relevant for remote attacks.
Comment removed (Score:5, Informative)
OpenSSH should block these (Score:3)
I've been blocking these "attacks" using a script+firewall for many years now. And I still think that, really, OpenSSH should have a configuration switch to block them internally. But BSD folks don't see it as a real threat, and they don't want to risk having actual users to get locked out of their servers. Fair enough, I guess.
So we're left with mitigation strategies. At 6 connections per minute, it's more a a nuisance than an attack, but I've seen rates as high as 200 connections per minute in the past, and there is no reason it couldn't go higher on an out-of-the-box OpenSSH configuration.
Some solutions, as others have pointed out:
- Have ssh listen on a port other than 22
- Turn on OpenSSH's internal rate limiting (MaxStartups config)
- Use key-based authentication
- Roll your own script to grep the log for failed connections, and firewall any IP addresses with 10 or more failures
A real brute-force attack would do a portscan first so putting ssh on a high port isn't much of a solution. Key-based auth is a nearly perfect solution, except that there are situations in which it is undesirable/awkward to use keys. The others just slow down the attack, which prevents the force part of brute-force.
Re:OpenSSH should block these (Score:4, Informative)
Why roll your own firewalling script? fail2ban works great.
In my experience fail2ban alone gets the attack rate down so low that they'll never succeed. They can scale the attack with more IPs, but large botnets aren't free and the price is apparently high enough for them to never bother any of my exposed machines.
Using PAM pam_access to block hail mary (Score:2)
---
When an attempt is made to login, sshd first checks authorized_keys and if the
I patched sshd to log attempted passwords (Score:2)
Re: (Score:2)
Here's an idea - route port 22 back to the connecting host. Then it will do a recursive bruteforce.
Re: (Score:2)
Might even work because the connecting host was prolly brute forced earlier. What you want to do if you get in is disable the machine somehow.
Re: (Score:2)
Re:Seems Easy To Detect (Score:5, Insightful)
Re: (Score:2)
One ping every 10 seconds isn't really a DoS attack. Unless it's one ping from each of a thousand machines every 10 seconds. But that's a DDoS attack, and it doesn't sound like that's what this is doing.
Re: (Score:2)
Yes the problem where an attacker can lock you out is annoying and is why I initially ignored Fail2ban, but timeouts get around that or in the worst case physical access to the machine. I don't think I'd use Fail2ban or similar on anything important that I couldn't get a
Re:WTF, Editors? (Score:5, Informative)