• Uncategorized

About linux : Is-it-possible-to-export-a-GPG-private-key-without-passphrase-being-provided-in-a-prompt

Question Detail

I would like to automate a GPG private key export so it runs without user interaction.

gpg --export-secret-keys [email protected]

I tried providing --batch --passphrase-fd 0 arguments both with passphrase being passsed as:

  • an argument --passphrase 'my-passhrase'
  • from stdin echo 'my-passphrase' | gpg ...

It didn’t work. Is it even possible to export private keys without user interaction?

Question Answer

You should add --pinentry-mode=loopback parameter, as well as --batch.
Full example from the RNP CLI tests suite:

gpg --batch --homedir .gpg ----pinentry-mode=loopback --yes --passphrase "password" --output keyfile.asc --export-secret-key userid

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.