News for hackers. Stuff that matters.
Re:Securing an Ubuntu Server by bryanh on Saturday March 12, 2011 @04:07PM (#2317506)
I go by the trifecta:

* Disable root login. * Change SSH port. * Install fail2ban or denyhosts.

Re:Securing an Ubuntu Server by SwellJoe on Saturday March 12, 2011 @06:08PM (#2317715)
Actually, the trifecta would be:

1. Update your software.

2. Use strong passwords, or public keys, for all accounts, regardless of how unimportant they seem. A strong password is one with letters, numbers, and possibly special characters, 8 or more characters in length, and is changed periodically.

3. Don't run unnecessary services or services with a poor recent security history.

Disabling the root login is a legit choice, though if someone figures out your sudo-capable account, you're equally screwed, so use strong passwords always.

Changing the ssh port only stops the people who aren't targeting you specifically, and even those people aren't always stopped. It is trivial to scan a host to find where ssh is running, regardless of the port you put it on.

fail2ban or denyhosts are OK for preventing brute force attacks, but OpenSSH and most security sensitive software already has timeouts, among other measures for preventing brute force attacks. Which makes fail2ban more of a nuisance-prevention measure (i.e. you see fewer brute force attacks show up in your log reports, and thus making it easier to see the more dangerous threats), rather than a core security measure.

If you performed your three steps, but ran an insecure version of any service (particularly those that have elevated privileges), you would still be easily exploited. fail2ban or denyhosts would prevent most services from being exploited due to weak passwords, so that's probably not a hole you'd have. And, changing the ssh port does nothing for you if your system hasn't been updated and is running exploitable services.

I used to do security cleanup and post-mortems and data recovery as a contractor for folks who'd had systems exploited. 90% of them were due to running old versions of software, and the rest were due to weak passwords (which may or may not have been prevented by fail2ban; in a couple of cases the exploiter used the webmail client to brute force the weak passwords...most people don't include the webmail client logs in their security considerations, and thus wouldn't configure fail2ban to ban attempts on the webmail client).

I'm not saying your advice is not useful, just that it's something you do after you get your core processes in order.

Edit: Formatting.

Re:Securing an Ubuntu Server by chanri on Saturday March 12, 2011 @08:42PM (#2318032)
Great advice! You sound like you have a lot of experience in server security.

What is your recommendation on strong passwords? Also, should all passwords on a system be different (login passwords for different servers, email passwords, etc...), and if so, how do you keep track of all of them?

Thanks

Re:Securing an Ubuntu Server by 16s on Saturday March 12, 2011 @11:06PM (#2318278)
Use SHA1_Pass for all of your passwords. It's awesome. Never store, type or forget a password again. Full disclosure, I'm the author.
Re:Securing an Ubuntu Server by SwellJoe on Sunday March 13, 2011 @01:40AM (#2318536)
This is a good way to go about it. I use Supergenpass session (the bookmarklet version is exploitable by websites you visit) for Chrome for websites, and keys for most ssh purposes. I have a couple of strong memorized passwords for situations where keys and supergenpass aren't convenient.

I'm totally on board with having one long/strong passphrase memorized and using it to generate strong, seemingly random passwords algorithmically, and I assume that's what SHA1_Pass does. So, yes, using SHA1_Pass is probably a good way to go about it.

Re:Securing an Ubuntu Server by _b8r0 on Sunday March 13, 2011 @05:54AM (#2318839)
I'm a bit conflicted by this.

On the one hand, the hex password in the screenshot while quite long has only 16 possible characters. The Base64 password has only 60 possible characters to choose from (for each position) and must end with an equals sign.

The number of possible characters for each position in the original sentence is quite high (94) but in a sentence the actual likelihood of a wide range of combinations being used is quite low (unless deliberately using obsfucation).

It's a very interesting piece of software and presents a very interesting question, which I guess is this:

For a given sentence, which out of Base64 encoding, Base 32, Hex and the sentence make for the most permutations required to crack? If the answer is Base64, 32 or Hex then your tool is helping. If the answer is the sentence then your tool is impeding. I suspect (but haven't done the maths) that for purely single case alphanumeric passwords it'll be base 64, but for mixed-case alphanumeric with punctuation it'll be the sentence. Anyone care to do the sums to lock this down?

Re:Securing an Ubuntu Server by SwellJoe on Sunday March 13, 2011 @05:39PM (#2320319)
I think you're missing the point of something like SHA1_pass: A different passphrase for every site. In the case of SuperGenPass, it hashes the site with the passphrase, making a unique passphrase for every domain. In the case of SHA1_pass, I would do something like, "My wacky passphrase 123 facebook.com" and "My wacky passphrase 123 google.com", etc. if I were to use it.

The sentence is only a piece of the hashed value, while some unique thing about what you're logging into is the rest of it. So, using "My wacky passphrase 123 facebook.com" as my password directly on facebook.com would mean that anyone with malicious intent and access to facebook.com code could easily figure out that every website where I have an account is "My wacky passphrase 123 sitename.tld". Strong password failure. The one-way hashed version of that has no meaning to the sites I log in to.

So, original sentence has very low security value, while a hashed version of it (assuming a unique piece for every site or service) has very high security value, even if the actual password generated is less strong than the original sentence from a purely "number of possibilities" perspective.

Of course, if you always use the exact same passphrase, and thus the same resulting password, your math would make sense...but the likelihood of an exploit is far more likely to come from people behind one of the sites you use sniffing your password, than from a brute force attack, in either case.

Re:Securing an Ubuntu Server by _b8r0 on Monday March 14, 2011 @04:39AM (#2321774)
As I understand it, SHA1_pass does the following (please correct me if I'm wrong or missing anything out):

* Takes a user supplied passphrase

* Makes a SHA-1 hash of the supplied passphrase

* Encodes the resulting hash in a variety of ways

I don't see where a different passphrase for every site comes in. You seem to be saying that you would append the site if you were to use it - you wouldn't need a tool like SHA1_pass to do that though.

I guess where I'm coming from is that I don't see what SHA1_pass does that provides any benefit over something like 1password or password gorilla, both of which can generate random passwords for arbitrary accounts.

Following your example, if I obtain your password on site A, then I get a hex|base32|base64 representation of a SHA-1 hash. I then put this into something like this (http://www.golubev.com/hashgpu.htm) and crack the SHA-1. I notice your algorithm for creating passwords and do the same. I'm now exactly where I would be if you weren't using your approach for a password on every site.

I appreciate that the SHA-1 element acts as an interesting intermediary, but your method for generating the password is predictable. I think a randomised SHA-1 might be better.

Re:Securing an Ubuntu Server by 16s on Monday March 14, 2011 @12:27PM (#2323117)
Author again. It should be used exactly as SwellJoe Described. The hash of "My Awesome password for Facebook!!!" should only be used on facebook.com. "My Awesome password for Twitter!!!" and so on.

The benefit of SHA1_Pass is that you never store, synchronize or backup passwords ever again. It's free, completely open-source and anyone can implement it and other software can be used to generate the hashes. Some of the password storage managers are not that way.

Re:Securing an Ubuntu Server by bryanh on Monday March 14, 2011 @10:56AM (#2322687)
Spot on advice, and a valid rebuttal. My trifecta was more in the spirit of securing against hundreds of brute force attempts, but I can't really knock your excellent advice.
Re:Securing an Ubuntu Server by _b8r0 on Sunday March 13, 2011 @05:43AM (#2318823)
That's a terrible trifecta.

* Disable root login

If you have root login enabled by default, you're using the wrong distribution. This is 2011, not 1996.

* Change the SSH port

Why are you doing this? What will you achieve by it? In what way does this reduce your overall risk of compromise, and by whom?

* Install fail2ban or denyhosts

That's the only thing out of your trifecta that should be in there. Aside from that, here's why your trifecta isn't a good move:

You're still using password authentication for SSH. Switch to public key authentication. This, combined with fail2ban or denyhosts means bots are not getting in. Period.

You aren't addressing your attack surface area - look at what information assets are exposed to the wider world and how. Once you know what your information assets are and how they can be accessed (either legitimately or unscrupulously) from the outside world you know what you have to protect and how people can get to it. That way you can focus on real countermeasures.

What about your applications? Have you checked your code to make sure you're validating input correctly? How are you protecting against SQL injection or Cross-Site Scripting? How are you handling state?

I put to you an alternative trifecta:

* Know your assets

* Know your threats

* Use appropriate measures to protect your assets from your threats.

Re:Securing an Ubuntu Server by rm-rf on Sunday March 13, 2011 @12:59PM (#2319597)
"* Change the SSH port"

"Why are you doing this? What will you achieve by it?"

Changing the port does not improve security. It does, however:

- dramatically reduce the noise associated with the fleet of password guessing bots that hit open SSH server daily.

- make it reasonable to assume that a password guess attempt is specifically targeting your serve, and therefor consideration for escalation and follow up.

Signal to noise ratio. Less noise make it possible to discover the signal.

Re:Securing an Ubuntu Server by _b8r0 on Sunday March 13, 2011 @01:39PM (#2319710)
> - dramatically reduce the noise associated with the fleet of password guessing bots that hit open SSH server daily.

But if you're already using fail2ban or denyhosts (as suggested in the trifecta) then you won't get that much noise anyway, and if you're only using public key auth then the noise from password guessing bots doesn't matter anyway.

> - make it reasonable to assume that a password guess attempt is specifically targeting your serve, and therefor consideration for escalation and follow up.

Unfortunately a failed authentication attempt regardless of port isn't enough to conclude that it's a targeted attack. Plenty of bots port scan common ports before running the tools to make sure they're attacking the right service. In fact some bots can do full portscans of hosts (although this is rare as it's quicker to scan for the attacks you have built in, thus you get more attack attempts in less time) - usually this is done to build a database of services, so that they can be exploited later when a new vulnerability comes out.

Regardless, as you say it doesn't improve security, there's no reason for it to be in any security-related trifecta.

Re:Securing an Ubuntu Server by getsat on Saturday March 12, 2011 @04:48PM (#2317586)
You're missing a really important ssh setting: disable password-based authentication!

However, this still won't protect you from vulnerabilities in your ssh daemon itself. Optimally, you would use Single Packet Authorization.

Re:Securing an Ubuntu Server by fierarul on Saturday March 12, 2011 @04:38PM (#2317574)
Wow, I didn't know of fail2ban and denyhosts.

I actually have a home-made script similar to fail2ban.

Re:Securing an Ubuntu Server by X-Istence on Saturday March 12, 2011 @06:56PM (#2317802)
I wrote a similar script way before fail2ban was ever created in around 2003 or so. When PF was first introduced. Since then I've just kept using it since it works particularly well for what I want it to do.
Re:Securing an Ubuntu Server by bmelton on Saturday March 12, 2011 @04:53PM (#2317595)
Yeah, I've written a number of very long, very gruelling scripts that ultimately were all replaced by denyhosts.

On the flip side, denyhosts only works on sshd (to my knowledge) -- so the scripts I wrote to monitor tornado log files and block all the random attack vectors is still worth having around.

Re:Securing an Ubuntu Server by mkelly on Sunday March 13, 2011 @01:26AM (#2318527)
denyhosts is configurable enough that I see no reason why it couldn't also work for other services. You'd probably have to hand-configure it (with a regex for each log type), though.

That said, I've only ever used it for ssh.

Re:Securing an Ubuntu Server by chanri on Saturday March 12, 2011 @05:52PM (#2317684)
What if you can't disable root login (i.e. it's a cloud server)?
Re:Securing an Ubuntu Server by rjbond3rd on Saturday March 12, 2011 @06:38PM (#2317764)
There's no reason you can't disable root logins on a cloud server. I do it every time.
Re:Securing an Ubuntu Server by dedward on Saturday March 12, 2011 @06:19PM (#2317733)
This is where firewalls come in handy...

Disabling remote root login isn't as big a deal as it used to be - as others have said, if someone gets your administrative account you're pretty screwed anyway - and if they get your password for sudo, it's the same thing.

Other than that, it really depends on what you mean by cloud.

Re:Securing an Ubuntu Server by steve19 on Saturday March 12, 2011 @06:14PM (#2317723)
Restrict root login from a particular IP address

AllowUsers [email protected]

I use AllowUsers to ensure only users I want can login from SSH.

Re:Securing an Ubuntu Server by spicyj on Saturday March 12, 2011 @07:01PM (#2317812)
But what if your IP address changes?
Re:Securing an Ubuntu Server by cuu508 on Saturday March 12, 2011 @07:19PM (#2317852)
Root login shouldn't be your normal entrance. For maintenance stuff use sudo-capable regular user account with public key authentication. If there's some software that requires root login and you cannot do anything about it, enable root login and allow it only from the specific IPs.
Re:Securing an Ubuntu Server by Estragon on Saturday March 12, 2011 @06:15PM (#2317727)
Why can't you disable root login on a cloud server?