So, I want to start using pass, but I need a GPG key for this. This application will store all of my passwords, which means it's very important that I don't lose my private key, once generated.

Hard disks break, cloud providers are generally not trusted. Not that I don't trust them to not mess with my key, but their security can be compromised, and all my passwords could be found.

So, where can I safely store my GPG private key?

  • Mine is simply stored in the OpenPGP application.
    – user40351
    Commented Feb 19, 2014 at 8:38
  • 2
    I keep my private key store on the cloud and on a thumbdrive that I usually have with me. Of course it has a good passphrase. It's really about balancing risk and accessibility. I could easily imagine a situation in which I'd handle my keys very differently. Commented Feb 21, 2014 at 10:24
  • 1
    Um, you do have good backups of your hard disk, right?
    – Bob Brown
    Commented Nov 13, 2014 at 12:13
  • On a smartcard.
    – user42178
    Commented Dec 30, 2014 at 7:52
  • 6
    pass can leak account information via its filenames and directory structure. This may or may not matter to you, but it's something to be aware of. Commented Sep 26, 2015 at 7:32

13 Answers 13


I like to store mine on paper.

Using a JavaScript (read: offline) QR code generator, I create an image of my private key in ASCII armoured form, then print this off. Note alongside it the key ID and store it in a physically secure location.

Here's some that should work for you no matter what operating system you use, as long as you have a browser that supports JavaScript.

For Windows users:

Click here to download the JavaScript QR code generator: https://github.com/davidshimjs/qrcodejs/archive/04f46c6a0708418cb7b96fc563eacae0fbf77674.zip

Extract the files somewhere, then proceed edit index.html per the instructions below.

For MacOS or Unix users:

$ # This specific version is to avoid the risk that if someone hijacks `davidshimjs`'s 
$ # repository (or he goes rogue), you will still be using the version that I vetted.
$ # For the truly paranoid you don't trust GitHub either, and you will want to verify the code you download yourself.
$ wget https://github.com/davidshimjs/qrcodejs/archive/04f46c6a0708418cb7b96fc563eacae0fbf77674.zip
$ unzip qrcodejs-04f46c6a0708418cb7b96fc563eacae0fbf77674.zip
$ cd qrcodejs-04f46c6a0708418cb7b96fc563eacae0fbf77674/
$ # We need to edit index.html so that it supports pasting your PGP key
$ # Open the file in a text editor like Notepad, vi, or nano
$ vi index.html

Change line 11 from:

<input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" /><br />


<textarea id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" /></textarea><br />

Now navigate to the directory you get here with Explorer, Finder, or Nautilus, etc.

For example:

$ pwd
$ open .

Viewing the directory in Finder

Now, double click on the index.html file you just edited and saved.

QR code being generated

You will most likely need to break up your PGP key into quarters or even smaller to create nice big QR codes that you can easily scan later. After pasting in the text area, click away from the text box and your QR code should appear. Save each one as you go and name them appropriately so that you know their order!

After you've created all the codes, scan them with, for example, a mobile phone QR code scanner app. For the paranoid, keep this device offline once you've installed a barcode reader and then perform a full wipe and factory reset of the device before putting it back online. This will prevent the QR scanner app from leaking your PGP key.

If you have a large key or lots of keys I recommend paperbak, although be sure to write down instructions on how to recover the data later. Just as important as how you back it up is how you restore it from a backup. I'd probably try this with dummy data just to be sure you know exactly how it works.

Worth noting you can protect your private key with a passphrase, so even if it's hosted with a cloud provider they can't see your private key, but then all your password security is reduced to that passphrase rather than the full private key, not to mention cloud providers can disappear overnight.

  • 8
    +1. I've been using hard copies for backing my private keys since 1997, and have had to restore them twice. First time I used plain ASCII text in Courier and had to use OCR to restore them, which worked but did need manual error correction. The second time I used barcodes (actually a sequence of long 1D barcodes rather than a 2D barcode) and the restoration process was much easier.
    – Jules
    Commented Feb 18, 2014 at 15:31
  • 9
    I do the same. Go the extra mile and think about how paper can degrade, e.g. If an inkjet print gets wet -- put the paper in a ziplock bag, put a second copy in a safe or safety deposit box etc. Commented Feb 18, 2014 at 20:01
  • 17
    Just as an option, paperkey also exists: jabberwocky.com/software/paperkey Commented Feb 19, 2014 at 9:03
  • 8
    @crdx This question was asked from a back-up point of view. For real time usage the most secure method would be an OpenPGP smart card with hardware pin entry.
    – deed02392
    Commented Feb 21, 2014 at 9:13
  • 5
    Don't forget to wipe the printer's memory afterwards. Commented May 18, 2015 at 2:49

On the days when my paranoia is like a ripe tomato, begging me to pick it, I split the private key (naturally it is already passphrase-protected) in half, then make a 3rd string by XOR-ing them together. Then I use simple password encryption (gpg --symmetric) on each string, and put each on a remote server on a different continent. Ideally, each remote server is with a different ISP or cloud provider.

But as the medicine was working -- at least until I realized how ambitious the NSA has been -- what I've actually done in the past is merely encrypted the (whole) private key (again using gpg --symmetric) and put it on my smartphone.

Now, having read the other answers, I'm finding the idea of three QR codes, embedded into three family photos, blindingly attractive. Time for stronger medicine?

  • 17
    "Time for stronger medicine?" -> You just made my day!
    – DBX12
    Commented Mar 24, 2017 at 15:24

This is not what I currently use, but I am thinking about it:

  1. Encrypt the private key with very long symmetric encryption key
  2. Use Shamir's Secret Sharing to split the symmetric encryption key to 7 pieces (like Voldemort), require at least 5 shares to merge successfully.
  3. Figure out where to put 7 secret backups, some ideas:
    • media card in a safe at home
    • printed paper in my wallet
    • in Dropbox
    • overseas safe deposit box
    • skin implants
    • buried in some random dude's grave
    • tattoed to poisonous pet snake

This way, I can lose access to a couple shares and still able to access the key; while an attacker would have to compromise 5 different individually secure places where it is easy for me to access but hard for evil dark lord's henchmen in that black car in front of the house <puts on tinfoil>.


One option is to encrypt your key using a passphrase, and store the encrypted key on a cloud service.

I have the key on my laptop (hardware encrypted drive) and on a Truecrypt container on an external hard drive as backup. Ok, it's not zero risk of data loss, but it's down to a level that is acceptable to me.

  • 9
    As mentioned in another answer, this is very convenient, but you reduce the security of all items protected by your key to the passphrase. You also run the very real risk that your cloud service is going to find itself with different business priorities someday (cf. ourincrediblejourney.tumblr.com) which could leave you high and dry.
    – Mattie
    Commented Feb 18, 2014 at 13:47
  • 1
    @zigg - if you use a decent passphrase then a cloud compromise is far from "high and dry"
    – paj28
    Commented Feb 18, 2014 at 13:49
  • 3
    "High and dry" wasn't about compromise. There are two different points being made here, broken by "You also…"
    – Mattie
    Commented Feb 18, 2014 at 16:26
  • 1
    Yes, this is only as secure as your passphrase... but you can use, say, a 40-character random passphrase, and print that on paper, which you keep someplace secure. This could be a lot easier than putting the entire key in a QR code, which may be hard to recover on a computer with no camera, or if the code is too damaged. (As for cloud services disappearing... so what? If Dropbox disappears tomorrow, all my dropboxed files are already synced to every one of my devices. I can sign up for a new cloud service the next day - no loss of data!)
    – Josh
    Commented Oct 21, 2016 at 18:46
  • @zigg "but you reduce the security of all items protected by your key to the passphrase" But isn't that always true no matter where you store keys? I would think the real weakness in the entire chain is how easy the physical/virtual location is to access from a malicious party, because the last step in any location option is always going to be cracking the passwords, so that should be assumed to be solid 70+ bit password or something and the real question really becomes where to put it. Commented Dec 5, 2016 at 1:51

You can keep your private key in a flash drive and keep this drive in a locker. Also, ensure that you don't use this flash drive for activities which might cause infecting it with some malware.

  • 13
    So, the day I need my key because I lost my computer, I go get the flash drive, and finds it's corrupted. What do I do? Commented Feb 18, 2014 at 9:52
  • 35
    I'm asking this question because I've stopped counting the number of USB keys I've seen corrupted. Commented Feb 18, 2014 at 9:58
  • 7
    @FlorianMargaine raises a great point. USB keys—and, for that matter, WORM (a.k.a. WORN—the N stands for "never") optical media—have bad track records. That said, I might consider using this in addition to another, less-convenient method of backup such as the paper methods presented in other answers.
    – Mattie
    Commented Feb 18, 2014 at 13:45
  • 3
    Actually, considering malware, SD card might be safer. And the small ones (up to 2GB) are quite reliable.
    – yo'
    Commented Feb 18, 2014 at 20:12
  • 5
    What I do is to store the key on a flash drive and paper. If I'm lucky, the flash drive just works. If not, then the key recovery is just a bit more inconvenient. Also, like with any important data, consider having more than one backup.
    – Miikka
    Commented Feb 19, 2014 at 8:07

I keep the key (and other sensitive data like a username / password list) encrypted in a truecrypt container. This container is protected by a massive passphrase. The container is also backed up on cloud storage so edits by any of my computers will be sync'd.

It's not perfect, but if the cloud provider dies, I still have it sync'd on my computers. If the file itself is compromised, they'd have to crack the truecyrpt phrase and the key passphrase.


I would use steganography to place the encrypted key in a series of 100 photos that I upload on several cloud storage (box, dropbox and ovh) for example.
So first you need to know there is something on those picture, find out what and decrypt it.
It's a bit extreme but it resist fire better than paper.

  • +1 for "it resist fire better than paper." I still think a clustered cloud service is better then paper. Commented Feb 20, 2014 at 10:42
  • 2
    If you've encrypted the secret key, you could just as well print it and store a PDF on a cloud service. Standardisation is a big problem with steganography - you may find the application you used has gone missing when you come to needing your key back.
    – deed02392
    Commented Feb 20, 2014 at 10:44
  • @deed02392 Well the method I propose is definitely extreme but was more here to show that if your want to hide things you have to be really careful. Also a readable pdf could be decrypted easily with a bit of brutforce while steganography implies to first find the information. but yes tools are rare and you better code your own.
    – Kiwy
    Commented Feb 20, 2014 at 10:50
  • 9
    Whilst I love the principle behind steganography, I've lost count of the number of files that have gone missing because I couldn't remember what picture I stored it in.
    – deed02392
    Commented Feb 20, 2014 at 10:52
  • @deed02392 you should give them filenames like "no_secrets_here.jpg". Or maybe just store a map somewhere on your computer. X marks the spot ;) Commented Dec 29, 2015 at 18:31

I have two keys, one less secure stored on the computer and another one in an OpenPGP Card. The latter is as safe as it possibly gets because the private key never leaves the chip on the card. (Though, years ago, for best security I had to slightly modify gpg to use my card reader's secure keypad instead of getting the card's PIN from the PC's keyboard which may be prone to keylogger attacks.)


I store mine inside a KeePassX encrypted file, this file is saved inside a git repository which I clone on all machines I need to use the passwords. The added benefit is that I can keep passwords synchronized while if the server for some reason destroys the file I can always use any of the cloned repositories. If I am paranoid I can put a truecrypt volume containing the KeePassX encrypted file.

Git also gives me versioning so I can always get back to previous versions of my passwords file, that's preatty neet.

  • 3
    Yo dawg, I heard you like encrypted files, so I...
    – IQAndreas
    Commented Sep 2, 2014 at 11:36

I really like the idea of having a very-long-term last-resort backup on paper. (Alongside an encrypted archival CD in a secure location.) I just can't find a QR generator that supports the full length of a private key, and I don't trust paperbak until they fix the AES key generation (plus it appears to be Windows-only).

I did find optar which will encode any length of data into a machine-readable format, but for now you have to compile it from C manually. [Shouldn't be hard to put something in Homebrew for Mac people, and perhaps a samaritan can maintain a Windows build, if it proves to work well.]

paperkey should be good for printing off / using OCR to restore a private key, and creating minimal characters for a barcode / QR code generator.


Do the following:

  1. Choose two numbers you like: R and C.
  2. Go to your private key row R and column C and memorize the character X you find there.
  3. Change that character to any other random value.
  4. Safely store your altered private key on more than one cloud service (different geographic locations.

The key stored there is useless without R, C and X (given that you know the trick, of course). If one can afford the time to find R, C and X, well... good luck now guessing my password.

Also memorizing R, C and X should be very easy from the perspective of the one introducing the change.

Hint: don't do it at the very beginning or end of the string. There are patterns to be followed there, it would be very easy to guess the change.


The private key is already encrypted. Encrypting it symmetrically once more wouldn't hurt though. After that the worry should be about physical security. Media durability and safety off site should be the main considerations. A usb key is probably ok for at least ten years as long as usb ports are available. Put the key in a safe place. A Safety deposit box or good safe off site are good possibilities. This should allow for a recovery in the event that the system you are using now breaks in some unrecoverable way. label and date the usb stick. An encrypted copy of the key's revocation certificate should also be stored with it. make a couple of duplicates if you are worried about usb stick failure.


disclaimer: pointing you to a piece of code I am writing / my own 'small' solution

For solving this kind of problems (and more generally 'archiving' important, moderate-size stuff on paper) I am working on qrdump, a way to automatically

  • 1) split your data into parts that are small enough to fit in qr-codes
  • 2) dump to a series of qr codes
  • 3) assemble the qr-codes with a predefined layout into a pdf.

Of course the inverse transformation is also implemented.

For example:

bash-4.4$ FOLDER_TESTS=$(mktemp -d)
bash-4.4$ cd $FOLDER_TESTS/
bash-4.4$ head -c 4096 </dev/urandom > dummy.dat # create a random file, 4096 bytes
bash-4.4$ sha256sum dummy.dat 
02f2c6dd472f43e9187043271257c1bf87a2f43b771d843e45b201892d9e7b84  dummy.dat
bash-4.4$ bash ~/Desktop/Git/qrdump/src/qrdump.sh --create-A4 --base64 --safe-mode --output ./pdf_dump.pdf --input dummy.dat # crete a printable qr-codes pdf of the file
SAFE to use: success restoring check
bash-4.4$ rm dummy.dat # the file is removed, so from now on only way to get it back is to restore from the pdf
bash-4.4$ bash ~/Desktop/Git/qrdump/src/qrdump.sh --base64 --read-A4 --input pdf_dump.pdf --output ./ # restore
bash-4.4$ sha256sum dummy.dat # the digest should be the same as the initial one to confirm good restore
02f2c6dd472f43e9187043271257c1bf87a2f43b771d843e45b201892d9e7b84  dummy.dat

If you are interested, more here:


You must log in to answer this question.

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