gpg: decryption failed: No secret key

gpg decryption works with version 1 using passphrase. But when using gpg version 2 it fails with 'No secret key'.


$ gpg --export [ID] > public.key

$ gpg --export-secret-key [ID] > private.key

$ gpg2 --import public.key

$ gpg2 --import private.key

You might also need to provide the gpg home dir.


GNUPGHOME=/root/.config/requests_gpgauthlib/.gnupg/ gpg2 -d /tmp/somedata

References:

https://github.com/IJHack/qtpass/issues/92

https://ask.fedoraproject.org/en/question/102451/pass-gpg2-decryption-failed-no-secret-key/