如何将 GPG 密钥移至不同的主机?导入时出错

如何将 GPG 密钥移至不同的主机?导入时出错

我正在尝试将我的 GPG 配置从家里转移到工作电脑上。这就是我导出密钥的方式:

sms@home-sms:~/Public$ gpg --list-keys
/home/sms/.gnupg/pubring.kbx
----------------------------
pub   rsa3072 2023-07-17 [SC]
      56D61B8B83BD3E534477DE20061D81ADCE33F311
uid           [ultimate] Szymon M. Sabat <[email protected]>
sub   rsa3072 2023-07-17 [E]
sms@home-sms:~/Public$ gpg --list-secret-keys
/home/sms/.gnupg/pubring.kbx
----------------------------
sec   rsa3072 2023-07-17 [SC]
      56D61B8B83BD3E534477DE20061D81ADCE33F311
uid           [ultimate] Szymon M. Sabat <[email protected]>
ssb   rsa3072 2023-07-17 [E]

sms@home-sms:~/Public$ gpg -a --export >pub.asc
sms@home-sms:~/Public$ cat pub.asc 
-----BEGIN PGP PUBLIC KEY BLOCK-----
[key]
-----END PGP PUBLIC KEY BLOCK-----
sms@home-sms:~/Public$ gpg -a --export-secret-keys >sec.asc
sms@home-sms:~/Public$ cat sec.asc 
-----BEGIN PGP PRIVATE KEY BLOCK-----
[key]
-----END PGP PRIVATE KEY BLOCK-----
sms@home-sms:~/Public$ ls
pub.asc  sec.asc

然后我将asc文件复制到我的另一台机器上,当导入密钥时(导入公钥没有问题),我收到错误:

sms@ubudev-sms:~/Admin$ gpg --list-keys
gpg: directory '/home/sms/.gnupg' created
gpg: keybox '/home/sms/.gnupg/pubring.kbx' created
gpg: /home/sms/.gnupg/trustdb.gpg: trustdb created
sms@ubudev-sms:~/Admin$ gpg --list-secret-keys
sms@ubudev-sms:~/Admin$ ls
packages.microsoft.gpg  pub.asc  sec.asc
sms@ubudev-sms:~/Admin$ gpg --import pub.asc 
gpg: key 061D81ADCE33F311: public key "Szymon M. Sabat <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1
sms@ubudev-sms:~/Admin$ gpg --import sec.asc 
gpg: key 061D81ADCE33F311: "Szymon M. Sabat <[email protected]>" not changed
gpg: key 061D81ADCE33F311/061D81ADCE33F311: error sending to agent: No such file or directory
gpg: error building skey array: No such file or directory
gpg: error reading 'sec.asc': No such file or directory
gpg: import from 'sec.asc' failed: No such file or directory
gpg: Total number processed: 0
gpg:              unchanged: 1
gpg:       secret keys read: 1

说明看起来很简单,我做错了什么?

相关内容