Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I have a public and secret key pair in my .ssh folder. How is the secret key being stored on disk? What I mean is .. Is it possible for someone to hack into my computer, steal the secret key and use it to decrypt all my messages which were encrypted with my public key?

Secondly, gpg requires a password to make use of the secret key. Does it not mean that someone can brute force the password and use the secret key anyways? After all, passwords are never as secure as secret keys ..

Or does the computer do some magic behind the scenes so that brute forcing the password that protects the secret key is simply impossible?

share|improve this question

migrated from crypto.stackexchange.com Apr 23 at 19:30

This question came from our site for software developers, mathematicians and others interested in cryptography.

    
I think the 'magic' you refer to is a password-based-key-derivation-function such as PBKDF2 or, ideally, Scrypt. It's a function that derives a cryptographic key from a password, and is computationally expensive to the point that brute-force attacks become infeasible. –  hunter Apr 23 at 15:54
    
OpenSSH uses an expensive key derivation function to turn your password into an appropriate symmetric key for encrypting your private SSH key. This will slow down a brute force attack considerably, but the difficulty is still proportional to the complexity of your passphrase. That said, if an attacker gains access to your machine, it's already game over; they can simply wait for you to enter your passphrase and capture it. –  Stephen Touset Apr 23 at 18:20
    
@StephenTouset I might be wrong, but I thought the OpenSSH KDF was pretty bad. Like 1000 rounds of PBKDF2 or something. They recently added bcrypt, though! \o/ –  Matt Nordhoff Apr 24 at 4:39
1  
@StephenTouset I Googled around. Before they added bcrypt in 6.5, it was one "round" of salted MD5! Oh my gods! (It was possible to use other tools to generate key files with a better KDF, and OpenSSH would read them fine, though.) –  Matt Nordhoff Apr 24 at 4:47
    
Ignore what I said, then. Shit. –  Stephen Touset Apr 24 at 15:33
add comment

3 Answers 3

up vote 5 down vote accepted

How is the secret key being stored on disk?

Like any other file is stored on disk.

Is it possible for someone to hack into my computer, steal the secret key and use it to decrypt all my messages which were encrypted with my public key?

Yes. Your private key is VERY important for this reason.

Does it not mean that someone can brute force the password and use the secret key anyways?

Yes, they can. Using a weak password to protect your private key will not guarantee you much security if your private key should fall into the wrong hands.

When it comes to public/private key cryptography, there is no understating how private your private key should be.

share|improve this answer
add comment

To add two things on top of James Mishra's excellent answer:

How is the secret key being stored on disk? What I mean is ..

OpenSSH supports optionally encrypting your private key with a password. With a sufficiently good password, it won't be possible to decrypt your key, even if an adversary has the file.

Is it possible for someone to hack into my computer, steal the secret key and use it to decrypt all my messages which were encrypted with my public key?

SSH uses forward secrecy, so they will not be able to decrypt your past communications. They will be able to impersonate you and obviously cause lots of other trouble.

share|improve this answer
add comment

To add Matt and James's answers, OpenSSL allows you to use pass phrases, which I highly recommend. This is arguably more secure than a password as it theoretically adds more entropy (how many possibilities exist), see http://xkcd.com/936/.

I say "arguably" and "theoretically" as it's still perfectly possible to bungle this using weak pass phrases. A recent study showed it was possible to brute force pass phrases using common terms. http://www.jbonneau.com/doc/BS12-USEC-passphrase_linguistics.pdf

My current practice is generating long strings of around 100 alphanumeric and symbol characters and storing them in Last Pass. This means my private key pass phrases don't have to mean anything to me, or be memorable at all but has the down side that if some were to work out my Last Pass pass phrase and get my private key, they'd be able to open it.

share|improve this answer
1  
Haha, a chain of answers adding to each other. 100 characters is rather a lot -- assuming an alphabet of 64 characters, that's 600 bits. I wouldn't use a password longer than 128 bits (22 characters). –  Matt Nordhoff Apr 23 at 14:08
    
If you don't need to remember it or type it, what would be the down side to having 100 characters... or more? –  DanielM Apr 23 at 14:20
    
@DanielM - Multitude of sites which have password limit set to 16, 30, 65 or other small values. Since I started using KeePass I generate 128 character passwords but I've already encountered a good number of sites which have upper limit on password length. –  Maurycy Zarzycki Apr 24 at 7:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.