I have several private keys that I use to ssh into AWS, dreamhost, github, etc. I have passphrases for all of these private keys that are too complex to remember. I have mysql passwords that my application and I both have to know.

Whats a convenient and secure way to keep track of all of this? My initial thought is that it might be useful to encrypt and tar a set of files with all this info, and put it on "the cloud" (dropbox, gmail). I can also put it on a usb stick that I keep on me at all times, but that's too easy to lose. Is there a better way?

Update I use lastpass for passwords, and it's decent. I'm not sure how to deal with private keys, or things like ssl certificates.

  • I don't know about lastpass, but my password vault (1password) can store arbitrary data such as text or file attachments. I put some of my software license keys in there. Never thought about putting private keys in there, but that's an interesting idea! Commented Aug 31, 2013 at 17:09

4 Answers 4


[Disclosure: I work for AgileBits, the makers of 1Password]

You already mentioned using a password manager for web logins. But for things like SSH and GPG/PGP private keys, you should consider a password manager which allows you to attach files to particular items and provides easy synchronization of this data.

Encrypted file systems.

Another option, not using a password manager, is to have an encrypted filesystem on some portable thing (USB thumb drive). The difficulty is finding a format that will work portably for you. If you only use OS X, then an encrypted DMG is an option, as you will be able to mount it and decrypt it on any Mac. I don't know what the Windows alternative is. Something like TrueCrypt might be an option, but you would need to also carry or install TrueCrypt wherever you go.

Things to avoid

I would avoid using something like a password protected zip file. First the password protection/cryptography isn't all that great, but more importantly it is too easy to end up leaving unencrypted data lying around.

I would also avoid trying to roll your own encrypted file system. There really are a lot of subtleties in designing such a system that most people aren't going to consider.

What I do

I, of course, use 1Password (see disclosure). Because it handles attachments, I can attach my various private keys to items in 1Password.


The biggest problem I have with this is that 1Password doesn't run on Linux or FreeBSD. (There are some open source projects to build a 1Password reader for such systems, but they aren't ready yet.).

Also as much as I trust 1Password and my 1Password Master Password, I still feel uncomfortable storing both my PGP private key file and its password in the same well-protected basket. So I store my PGP private key in 1Password, but I rely on my memory for that particular passphrase.

  • Good to know that 1Password supports attachments and can handle keys, also, thanks for playing ball and being honest with the disclosure. Commented Aug 30, 2013 at 20:54
  • 1
    Ahh a 1password employee! I'm glad to hear that I'm not the only person who wishes it had linux support. Why not make a chrome extension that can read the file off of Dropbox? Even if it's read only, it's still way better than logging into the web interface every time. Commented Aug 31, 2013 at 17:14
  • Thanks @mehasse. Interesting idea, but we are trying to reduce amount of crypto done in browser. We can't "endorse" 3rd party readers, but we wouldn't complain if someone developed something like that. Commented Aug 31, 2013 at 21:26
  • 1
    @mehaase I have had luck running 1Password for Windows in Wine. Sure I have to copy-paste all my logins, but at least I have access to them in an app on my machine. +1 Linux support for sure though!
    – Urda
    Commented Sep 12, 2013 at 20:49

The "file full of passwords" is fine but requires some care when using it. When I travel with mine, I encrypt it with GnuPG and I decrypt it only on a portable computer (mine, so it is "clean") which runs Linux, without any swap space activated, and I decrypt only in /tmp, which I have configured as a "memory file system" (tmpfs) backed with RAM. The point of the exercise being to prevent any of my precious passwords to ever hit unencrypted a permanent data storage (the internal hard disk / SSD).

Some password manager applications (e.g. KeePass) can automate this process and give you an easier-to-use system.

Another method is to switch to mathematics at the time of generation of the passwords. The idea is to store in your mind a single "master password" (make it big and very random; say 20 random letters). When you need to generate a password for some usage U, then simply apply some deterministic cryptographic operation (say, hashing) which involves both U and the master password. "U" here will be a string using a format (any format that you wish) which somehow encodes the destination of the password.

For instance, make U the string "ssh:foo.example.com" to mean "the password used to connect with SSH to the machine foo.example.com". The encoding does not matter much as long as it is unambiguous, i.e. you can dynamically rebuild the string from your knowledge of the situation ("I want to connect with SSH to foo.example.com") and you won't have collisions (two distinct usages which end up on the same usage string).

The "cryptographic operation" which combines the master password and the usage string into a password must be designed with some care. I suggest using PBKDF2, the usage string U being the "salt". The iteration count for PBKDF2 is a trade-off: a higher count protects your master password better, but implies a higher cost when you want to recompute a password. An iteration cost of about one million is probably adequate.

I don't have a handy reference to an existing product which does that, but I am sure such products exists; and it could otherwise be reimplemented easily with a simple .NET application (.NET has an implementation of PBKDF2 since .NET 2.0 and it is also available on the Linux port Mono).

The point of using mathematics is that you don't have anything to store: the application (public, fixed) and the master password (private, never stored anywhere but in your head) conceptually "contain" all the passwords for a virtually infinite number of usages. Challenges with that kind of solution are:

  • You need to encode the PBKDF2 output (a sequence of bytes) into a "password" which will be considered acceptable "everywhere". Unfortunately, every site, server or application which accepts passwords can have its own restrictions (minimum length, maximum length, set of acceptable characters, set of NOT acceptable characters...) and it is unclear whether you can design a single encoding resulting in passwords which work for every system.

  • For the same destination (our "usage string"), you always get the same password. Some sites / systems force password changes on a regular basis (for no really rational reason, but that's humans for you). You can support such things by including the current date (month and year) in the "usage string", but it is cumbersome to have to remember whether a given site needs such rotating passwords or not.

So while this method has some elegance, it may be impractical until some heavy thinking and tinkering is invested in the creation of a product which does the job (the product can be a command-line tool with a short code).

Edit: as for your update, once you can store passwords, you can always encrypt arbitrary files with GnuPG (symmetric encryption with a password: gpg -c). Thus, you can store anything that way, including private keys for certificates.


A lot of us use programs like KeePass to keep track of accounts. It securely encrypts them and keeps them organized. It also has clients available for most smartphones and desktops, so you can access your passwords wherever you are.

  • I updated the question to mention I do use lastpass sometimes, but it doesn't cover all my use cases.
    – TJ Shah
    Commented Aug 30, 2013 at 17:31
  • as long as it's not cosmic top secret, keepass et al is just fine, also for handing passwords out to clients and telling passphrases via telephone or text-message. and if you use linux its just 2 clicks away :) Commented Aug 30, 2013 at 20:48

You can give a try to KeePassX. At least in Linux, in each entry you can save a file. Probably it will not "open" automatically private keys or certificates, but at least you a safe spot to put all critical information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .