Are exported private keys in GPG still encrypted?

ExportPrivate KeyGnupg

Export Problem Overview


Are the exported private keys gotten by executing gpg --export-secret-keys still encrypted and protected by their passphrase? This seems to be the case but I can't find anywhere that explicitly confirms this.

If the exported keys are still encrypted then is there anyway to get the pure, unencrypted private key (like you can for the public segment)?

Export Solutions


Solution 1 - Export

Exported secret keys are encrypted by default, however --export-options export-reset-subkey-passwd will produce an unprotected export:

> When using the --export-secret-subkeys command, this option resets the passphrases for all exported subkeys to empty. This is useful when the exported subkey is to be used on an unattended machine where a passphrase doesn't necessarily make sense. Defaults to no.

Solution 2 - Export

Are exported secret keys still protected by their passphrase? You could find the answer to this so easily by exporting and then importing a secret key.

GnuPG has no simple way to export a private key in the way you describe. I can only hope you have a good reason for wanting to do this, and that you're aware of how dangerous it is to let the bits and bytes of an unprotected private key touch a disk. That said, the only option I see is to remove the passphrase before exporting...

gpg --edit-key KEYID
> passwd
> *(Press Enter twice, i.e., use a blank passphrase)*
> save

PS: This should be moved to Superuser; it's off-topic here.

Solution 3 - Export

Yes secret keys are encrypted after exporting. Once you've imported the private key file via the following command:

gpg --import <name of your private key>.pgp

It will prompt you to enter the correct passphrase (same passphrase used to create the private key in the first place).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatukuView Question on Stackoverflow
Solution 1 - ExportmshroyerView Answer on Stackoverflow
Solution 2 - ExportrsawView Answer on Stackoverflow
Solution 3 - ExportshalamusView Answer on Stackoverflow