News for hackers. Stuff that matters.
Re:Ask HN: What are the best practises for using SSH keys? by dsl on Sunday September 25, 2016 @07:59AM (#12574956)
From my experince as an attacker --

   - Is it better to use a different passphrase on each key, or does using the same one not matter much?
   - How much less secure is it to not use a passphrase on a key?
   - Should you use a different key per user account, per server, or per use-case (i.e. personal or work)?
None of these things really matter that much. Make sure you use full disk encryption and never stand up from your machine without locking it, and make sure you keep your local machine patched. If I get code execution on your machine, I am going to use whatever keys are loaded in your ssh-agent to pivot, hijack your existing open sessions, or modify your ssh client to dump the keys I need.

   - Does increasing the amount of bits in a key really have an effect on the security of the key, or does it not make much difference in a real-world use?
Key length is a protection against the future, and against state level actors. Right now, key length doesn't matter much to me because I'm more focused on just stealing your keys from you regardless of length.
Re:Ask HN: What are the best practises for using SSH keys? by berdario on Sunday September 25, 2016 @08:38AM (#12575074)
Indeed, I have FDE enabled and a passphrase, but I reckon that the passphrase is not buying me much.

OTOH, it's defense in depth, and there are some vulnerabilities which could allow to exfiltrate keys without non-sandboxed-RCE

https://blog.mozilla.org/security/2015/08/06/firefox-exploit...

I reckon that a passphrase protected key would be safe from this attack (modulo offline brute-forcing)

Re:Ask HN: What are the best practises for using SSH keys? by regecks on Sunday September 25, 2016 @08:41AM (#12575087)
> OTOH, it's defense in depth

Yup. IMO not using a passphrase is nuts, considering there is practically no convenience loss (ssh-agent, OS X keychain, pageant) and fairly significant benefit. Protects against:

- accidentally exposing the private key (it happens, accidental wildcard in the shell), and

- attacks that aren't after your keys specifically, e.g. your home directory gets stolen.

Re:Ask HN: What are the best practises for using SSH keys? by eropple on Sunday September 25, 2016 @04:43PM (#12577318)
In general I agree with you, with the caveat that there are a number of products that don't give a toss about security (lookin' at you, Hashicorp) that actually and unironically require you to have your keys unencrypted on disk.

I have since discarded these products (and others should too), but they do exist.

Re:Ask HN: What are the best practises for using SSH keys? by carlesfe on Sunday September 25, 2016 @09:33AM (#12575236)
Nobody seemed to answer this question, and neither did the original blog post (besides "trust me and do it"), so maybe you can shed more light on the main point:

Why are ED25519 keys better than RSA, how compatible are they with different systems, and are they worth the hassle and risk of generating and using a new one?

Re:Ask HN: What are the best practises for using SSH keys? by lisper on Sunday September 25, 2016 @10:05AM (#12575358)
> Why are ED25519 keys better than RSA

Two reasons: 1) they are a lot shorter for the same level of security and 2) any random number can be an Ed25519 key. To generate an RSA you have to generate two large random primes, and the code that does this is complicated an so can more easily be (and in the past has been) compromised to generate weak keys.

Re:Ask HN: What are the best practises for using SSH keys? by carlesfe on Sunday September 25, 2016 @04:19PM (#12577203)
If I understood it correctly, you're saying that RSA requires the two numbers to be big AND random, otherwise the algorithm isn't strong? Therefore Ed25519 is better because it's strong regardless of the key?

What I don't get then is how can a short key be secure, that goes against what I was taught in college. Aren't shorter keys more prone to collisions and bruteforce attacks?

Re:Ask HN: What are the best practises for using SSH keys? by rosser on Sunday September 25, 2016 @04:25PM (#12577240)
Aren't shorter keys more prone to collisions and bruteforce attacks?

Given the same cipher, more or less, yes. Between ciphers, though, key-lengths are less relevant, and the differences in those ciphers become more so.

EDIT: Think of it in terms of Shannon Entropy: because RSA requires a pair of primes, the keyspace is so much sparser — that is to say, more "predictable" (if, granted, at a mostly theoretical level) — so keys need to be that much larger to be secure.

Contrarily, with ED25519, keys can be smaller, because the keyspace is denser.

(Or am I just talking out my ass here?)

EDIT 2: s/smaller/sparser/, s/bigger/denser/, regarding keyspaces. Thanks, 'lisper!

Re:Ask HN: What are the best practises for using SSH keys? by lisper on Sunday September 25, 2016 @04:54PM (#12577383)
Not bigger -- denser.
Re:Ask HN: What are the best practises for using SSH keys? by carlesfe on Sunday September 25, 2016 @05:56PM (#12577671)
Great replies, I got it now, it makes sense. Thanks to both of you!
Re:Ask HN: What are the best practises for using SSH keys? by lisper on Sunday September 25, 2016 @04:53PM (#12577382)
RSA requires two numbers which are big and random and prime. It is the primality that makes things tricky. Generating random primes is a lot harder than generating random numbers.

The other factor (no pun intended) that makes RSA keys large is that there are more efficient algorithms for factoring than there are for solving the elliptic curve discrete log problem, e.g. https://en.wikipedia.org/wiki/General_number_field_sieve If you crunch the numbers on this you will find that a 2000-bit RSA key has a security level of about 100 bits, i.e. it takes about 2^100 operations to factor a 2000-bit RSA key using GNFS.

Re:Ask HN: What are the best practises for using SSH keys? by YomiK on Monday September 26, 2016 @09:11PM (#12586909)
Not disagreeing, but I think both randomness and primality testing both have the problem that it's so easy to do them poorly. Generating random primes of these sizes isn't all that difficult, and even proofs can be done in reasonable time frames (e.g. under 10 seconds for 1024-bit inputs). There are also a couple random proven prime algorithms which run pretty fast. Getting software to correctly implement everything .... that seems to be hard.
Re:Ask HN: What are the best practises for using SSH keys? by lisper on Monday September 26, 2016 @09:30PM (#12586949)
> Getting software to correctly implement everything .... that seems to be hard.

Exactly. Generating random primes is not terribly difficult in theory, but in practice it is very tricky, which makes it hard to answer the question: how do you know you can trust your keys? Sure, you can verify that your primes are prime, but how do you know how much entropy they have? The only way to figure that out is the audit the code. (And then you have the problem of making sure that the code you're running is the code you audited.)

Generating random numbers is also tricky, but a lot less so than generating random primes: take an entropy source and run it through a whitener, i.e. feed it to sha512. As long as you have a reliable estimate of the lower bound of the quality of your entropy source, you're good. A lot fewer moving parts.

Re:Ask HN: What are the best practises for using SSH keys? by arca_vorago on Sunday September 25, 2016 @09:58AM (#12575328)
ED25519 keys are cryptographically more secure, and are more politically secure if you want to call it that due to the undermining of NIST the NSA was/is doing. (plus it comes from djb, all hail djb!)

OpenSSH already has support built in, as does Mosh, and therefore, I do think it's worth it.

I do sometimes disagree with using keys though, despite everyone pushing it so hard, there are cases where I think passwords are the way to go, but thats a long post for another time.

Also, I really like usin pam auth mods, such as yubikeys or google auth for two factor. That combined with regular hardening, and yes Ill admit it, non standard ports (reduces log alert fatique) does a pretty good job.

Re:Ask HN: What are the best practises for using SSH keys? by effie on Sunday September 25, 2016 @04:49PM (#12577364)
> I do sometimes disagree with using keys though

That sounds interesting, could you elaborate on that?

Re:Ask HN: What are the best practises for using SSH keys? by duaneb on Sunday September 25, 2016 @04:35PM (#12577287)
Note that ED25519 is more vulnerable to quantum computation than is RSA.
Re:Ask HN: What are the best practises for using SSH keys? by rosser on Sunday September 25, 2016 @06:20PM (#12577760)
If, like most such claims I've seen lately, you're referring to No Such Agency's recommendation against adopting Suite B, the reasons behind that move seemed to me not to be about ECC being "more" QC vulnerable than RSA. They simply said, "If you haven't made this switch already, just keep using RSA while we figure this whole 'quantum' thing out."

ECC and RSA are both ultimately going to fall to practical quantum computing, and probably over a time frame short enough that it won't matter which cipher you picked.

Re:Ask HN: What are the best practises for using SSH keys? by maquetaurie on Sunday September 25, 2016 @10:48AM (#12575559)
In your experience what difference does full disk encryption vs home encryption have in this context? We've been debating this a lot at work.
Re:Ask HN: What are the best practises for using SSH keys? by spydum on Sunday September 25, 2016 @12:15PM (#12575916)
FDE leaves very few if any opportunities for accidentally spilling cleartext secrets onto the disk. If by home encryption, I assume you mean some encrypted container (or encrypted document). Consider what you "DO" with the decrypted contents.. often you are copying them out to perform some action (authentication, etc).. Are you certain the apps you use and your clipboard won't be paged to disk temporarily? If secrets are in memory, then get paged to disk, is your swap encrypted? It is more likely you are still protected if using FDE (depends on your setup).

All that being said, thats a certain level of paranoia which i dont think is productive.. but perhaps for targets of the state or what have you, I'd rather not chance it.

Re:Ask HN: What are the best practises for using SSH keys? by ytjohn on Sunday September 25, 2016 @03:42PM (#12577013)
I think in this case, "home" encryption is what I use. Most Linux systems when you install will offer to encrypt your home folder. When you login, your password unlocks a key which ecryptfs uses to virtually mount a directory filled with encrypted files to be your home directory. As long as you are logged in, the home directory contents are available (transparently). When you logout, the virtual mount is destroyed, leaving behind only the encrypted files.

To put it in perspective, if you were logged out completely and tried to login remotely, you would be forced to use a password login initially. If it was more like my desktop where I'm logged in and the screen in locked, the home folder is unlocked, so I can remotely ssh in using just my keys.

Re:Ask HN: What are the best practises for using SSH keys? by michaelt on Sunday September 25, 2016 @03:35PM (#12576969)
The default encryption on Ubuntu, if you select 'Encrypt my home folder' during setup, uses ecryptfs on your home folder, and cryptswap for swap. For some reason, /tmp/ isn't encrypted by default as far as I can tell.

AFAIK the main benefit is: if you want to run a multi-user or headless system, you need the network stack brought up before a password is entered - which home directory encryption provides and FDE can't.

Re:Ask HN: What are the best practises for using SSH keys? by majewsky on Sunday September 25, 2016 @06:35PM (#12577828)
> For some reason, /tmp/ isn't encrypted by default as far as I can tell.

It does not give any extra benefit because tmpfs only resides in RAM, and disk encryption typically only concerns data at rest.

If you come to a point where you want to have /tmp/ encrypted, you would rather encrypt the whole RAM. (Does anyone actually do that?)