I am using gpg and generated, imported and signed keys.

How can I take all of the work that I have done and export all of my keys then import them into another machine?

migrated from stackoverflow.com Oct 13 '09 at 15:53

This question came from our site for professional and enthusiast programmers.

up vote 5 down vote accepted


  gpg --export my_key -o my_public_key.gpg
  gpg --export-secret-key my_key -o my_secret_key.gpg


  gpg --import my_public_key.gpg
  gpg --allow-secret-key-import --import my_secret_key.gpg
  • I am going to try this sometime this week! Thanks satanicpuppy! – Daniel Oct 19 '09 at 22:05
  • The options used: -o, --output use as output file – Daniel Oct 28 '09 at 23:28

Traditional PGP let you just copy the keyring files around, or just merge them by invoking it on the keyring to import. I've not kept up with GPG, but I'd be surprised if it differed significantly.

Actually, if you were being properly paranoid, the private keyring should live on a thumbdrive or similar removable device, with perhaps a securely stored CD-R or similar for backup), so that part would be moot.

You can just copy pubring.gpg, secring.gpg and trust.db from the old machine to the new one.

  • secring.gpg contains all your private keys
  • pubring.gpg contains all your public keys (imported, signed keys)
  • trust.db contains yout user trust settings (if used)

HTH, Jan

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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