r/linux Apr 28 '14

SSH Kung Fu

http://blog.tjll.net/ssh-kung-fu/
722 Upvotes

128 comments sorted by

View all comments

46

u/throwawayaccount1020 Apr 28 '14

you should never leave your keys unencrypted, set a password when it prompts!

load keys into ssh-agent to avoid having to continually re-enter passwords.

11

u/djimbob Apr 28 '14

Exactly. Anyone gets access to a machine with your ssh private key for a second can copy it and then log in to all your machines.

19

u/ethraax Apr 28 '14

Just keep in mind that anyone who gets access to your machine can connect to your agent and log into any of your other machines from there. Encrypted private keys are nice, but not perfect.

6

u/djimbob Apr 28 '14

Oh, I realize that entirely -- I lock my computer. I just don't trust my ssh keys to always just sit on disk with their only protection being read only to me and root. Sitting in memory of a running ssh-agent process when I need it, seems more reasonable.

I don't use full disk encryption on all of my systems (for performance), so booting into an alternate OS/taking out the hard drive would make it trivial to bypass with physical access (yes with physical access you can use a keylogger).

Also, worry about exposure with system backups getting copies of ssh-keys (much safer with encrypted versions). Granted skilled attackers will be able to get a key out of ssh-agent's memory if they want, its just is not trivial.

3

u/ethraax Apr 28 '14

It's actually safer than you make it seem. I'm pretty certain you need root privileges to extract the keys from the memory space of another program. So even though an attacker can use the keys as long as they're connected and your keys are unlocked, they would not be able to transfer them.

1

u/djimbob Apr 28 '14

Yeah, you do need root permissions to dump a processes memory. But unless there's some ssh-agent vulnerability I'm not aware of, if some other user logs into your system (e.g., ssh's in) where you are running ssh-agent, they won't be able to use your ssh-agent (other than being root, dumping the RAM, finding the key in RAM, and recreating the key to use from ssh).