我已经将 gpg 密钥从 linux 导出到 Mac。在 linux 上导出命令如下
gpg --export-secret-keys -a test_01.asc
gpg --export -a test_01_pub.asc
Mac上导入命令如下
gpg --import test_01.asc
gpg --import test_01_pub.asc
但是当使用导入的密钥解密时,
gpg -d -vvv test_01.gpg
gpg 说
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
当我尝试更改其密码时
gpg -vvv --edit-key XXXXXXXXXXXXXXXX
passwd
gpg 说
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.
Linux 和 Mac 上的 gpgs 版本分别为 2.2.41 和 2.4.0
答案1
谢谢你的解释。问题已经解决了。重新生成一个新的目录 ~/.gnupg 并配置 pinentry-mac 以进行 PIN 输入后,密钥导入过程会提示输入 passwd,并且密钥导入成功。