Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made a keypair for my email address using gnupg. I thought that I should probably keep a backup of it so that if I lose my desktop computer I can continue using the same key.

Is this the correct thinking?

How can I export my private key / the whole pair?

share|improve this question

Have you tried:

gpg --export-secret-key

That should do it. You might have to give the id of the key you want to export. And maybe also provide --armor if you want it in nice ASCII.

You don't need the public key because the public key can always be trivially generated from the private key.

Keeping a backup is likely a wise idea. I also tend to generate a revocation signature (the --gen-revoke option) that I don't publish and keep that backed up too, often in a separate place. This allows me to revoke the key if I lose it or it becomes compromised in some other way.

I strongly recommend you you keep the key backup offline.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.