Skip to content

Comment on Improving the security of your SSH private key files

Comments

While its actually an interesting post, the truth is: Don't copy your private keys around. Keep em on your desktop/laptop.

Making your passphrase twice harder to crack is nice.. but whats 15 days instead of 7? Making your passphrase 10000x harder to crack would also be nice... but why care, if i have access to the file, i can just record your keystrokes when you type the passphrase.

And that's why you can use an ssh-agent, and probably why OpenSSH doesn't care much about changing the key format.

If you do not trust your laptop, the problem is still there. You can still capture the keystrokes easily if you have access to the file, anyways.

I would suggest using something like a cryptostick or any openpgp smartcard when the laptop is not trusted (actually, even if its relatively trusted I would still recommend it!). This ensures the key is never transferred somewhere it can be copied.

> This ensures the key is never transferred somewhere it can be copied.

But it does not ensure that the computer will add another entry to the authorized_keys file in the host as soon as you access it. Or install a rootkit there with another kind of backdoor.

If you don't trust your computer, don't give it access to your servers.

This is why I haven't bothered with smartcards. If you login from a compromised desktop, it's pretty much over, even with a smartcard.

There is no real way around the evil maid attack. If I login from a compromised computer, if that computer is compromised by a competent attacker, it's over.

The advantage of a smartcard, if and only if you've got a smartcard that requires some action to authenticate (like a physical pin pad) is that only the servers I've logged into while compromised are compromised (assuming you don't have some kind of jelly doughnut setup where all servers can login to all other servers) whereas if I have an encrypted private key, well, if I decrypt it while the attacker is on the box, the attacker has compromised /all/ servers I have a login on.

I'm not sure if I understand what you're saying, or if _you_ understand what you're talking about to be honest.. ;-)

If you need to access a server you'll always need a computer. authorized_keys are public keys only. it does not matter if other computers have your public key. all it does is give you access.

the private key of your ssh key(s) give access to several servers, thats why its the part that you want to protect. if one server has a rootkit, well, that sucks. but if that rootkited server can access all the servers YOU can access, you're screwed.

He's saying a latent program could hijack your established ssh connection to add another public key corresponding with an attackers private key to get long term access.

> Making your passphrase twice harder to crack is nice.. but whats 15 days instead of 7? Making your passphrase 10000x harder to crack would also be nice

You mean like doing 10000x iterations of md5? Btw, it's not even 15 days instead of 7 any more. You need to measure it purely in money. EC2 cost is nodes * time, so if you need to double the time it is just doubling the cost.

What prevents a compromised laptop from reading your private key in the clear from your smartcard? Even if you need a fingerprint read or PIN, I mean at some point you need to get the decrypted key read from the card so that it can be used.

The private key is not accessible outside of the smart card. All the cryptographic operations that require the private key are done by the smart card itself. Cryptographic smart cards are not just a dumb storage device, they are basically a computer. They have a CPU (my card has a 66Mhz 32bit RISC CPU) and normally run some simple OS. You can actually write applications that can run on the smart card using, for example, a subset of Java or the .net framework.

Edit: For example, you can view what is currently running on the smartcard: http://i.imgur.com/Pgwz4la.png or view the filesystem on the smartcard: http://imgur.com/aLsV6pf

Ah, I guess that's why they are called "smart". Thanks, learned something.

You may be interested to know that RFID cards are also 'smart', although less so. They have hardware circuits that can perform some cryptographic routines, and receive enough power to perform many calculations. So an RFID reader will send a challenge, the card will perform some operations based on a secret key, and send back the result. The reader is connected to a central database, that also knows this secret, so it knows if the response is valid. As such you can't just 'copy' an RFID card, or even replay a valid request (since the challenge is unique).

This is straying out of my knowledge, but I'm pretty sure most smart cards perform the encryption on the card itself. The public key can be exported, but without specialized hardware and/or software (that you hopefully don't run all the time in an unlocked fashion), you can't extract/set the private key.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.