I have exported a gpg key from linux to Mac. Exporting commands on linux are as follows

gpg --export-secret-keys -a test_01.asc
gpg --export -a test_01_pub.asc

Importing commands on Mac are as follows

gpg --import test_01.asc
gpg --import test_01_pub.asc

But when decrypting with the imported key,

gpg -d -vvv test_01.gpg

gpg said

gpg: using character set 'utf-8'
gpg: enabled compatibility flags:
# off=0 ctb=85 tag=1 hlen=3 plen=268
:pubkey enc packet: version 3, algo 1, keyid XXXXXXXXXXXXXXXX
        data: [2048 bits]
gpg: public key is XXXXXXXXXXXXXXXX
# off=271 ctb=d2 tag=18 hlen=2 plen=62 new-ctb
:encrypted data packet:
        length: 62
        mdc_method: 2
gpg: using subkey XXXXXXXXXXXXXXXX instead of primary key XXXXXXXXXXXXXXXX
gpg: encrypted with rsa2048 key, ID XXXXXXXXXXXXXXXX, created xxxx-xx-xx
      "xxx <xxx@xxx.com>"
gpg: public key decryption failed: Bad secret key
gpg: decryption failed: Bad secret key

And when I tried to change its passwd, gpg said

error getting keyinfo from agent: System error w/o errno
pKey has only stub or on-card key items - no passphrase to change.

The versions of gpgs on Linux and Mac are 2.2.41 and 2.4.0

  • You need to export and import both the private and public keys. How did you do this?
    – harrymc
    Mar 17 at 16:58
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Mar 17 at 17:45
  • I have added the exporting and importing commands in the description. Are they proper for exporting keys from linux to Mac?
    – user219155
    Mar 18 at 17:24

1 Answer 1


Thanks for the explaining. The problem has been solved. After regenerating a new dir ~/.gnupg and configing the pinentry-mac for pin entrying, the key importing process prompts for passwd and the key is imported successed.

New contributor
user219155 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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