0

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 <[email protected]>"
gpg: public key decryption failed: Bad secret key
gpg: decryption failed: Bad secret key

And when I tried to change its passwd

gpg -vvv --edit-key XXXXXXXXXXXXXXXX
passwd

gpg said

gpg: key XXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXX: error getting keyinfo from agent: System error w/o errno
gpg: key XXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXX: error getting keyinfo from agent: System error w/o errno
Key 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

2
  • Mac line ending is \r, Linux is \n... maybe that?
    – peterh
    Commented Mar 22, 2023 at 0:29
  • Did you by any chance create the keys with a security module, either internal or removable (such as a smart card or Yubikey)? That would create "stub" private keys which are not actually exportable, though it should be possible to use the stubs on another system if you move the security module over too.
    – CBHacking
    Commented Mar 22, 2023 at 6:16

1 Answer 1

0

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.

Not the answer you're looking for? Browse other questions tagged .