从 GnuPG 2.2.6 开始,有一个隐藏的键编辑子命令“change-usage”可以做到这一点。相关提交。
让我们用测试键试试这个子命令。我们先创建一个:
mkdir /tmp/gpg-change-usage
chmod 700 /tmp/gpg-change-usage
gpg --homedir /tmp/gpg-change-usage --quick-generate-key someone@example.com rsa4096 cert 1d
现在请注意,这个新密钥是仅认证的主密钥。
$ gpg --homedir /tmp/gpg-change-usage -k
/tmp/gpg-change-usage/pubring.kbx
---------------------------------
pub rsa4096 2019-04-04 [C] [expires: 2019-04-05]
987BE3D9CF90B1C912A165734EBF4D26A937DE4C
uid [ultimate] someone@example.com
改变用法很简单:
$ gpg --homedir /tmp/gpg-change-usage --edit-key someone@example.com
gpg (GnuPG) 2.2.12; Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
sec rsa4096/4EBF4D26A937DE4C
created: 2019-04-04 expires: 2019-04-05 usage: C
trust: ultimate validity: ultimate
[ultimate] (1). someone@example.com
gpg> change-usage
Changing usage of the primary key.
Possible actions for a RSA key: Sign Certify Encrypt Authenticate
Current allowed actions: Certify
(S) Toggle the sign capability
(E) Toggle the encrypt capability
(A) Toggle the authenticate capability
(Q) Finished
Your selection? s
Possible actions for a RSA key: Sign Certify Encrypt Authenticate
Current allowed actions: Sign Certify
(S) Toggle the sign capability
(E) Toggle the encrypt capability
(A) Toggle the authenticate capability
(Q) Finished
Your selection? q
sec rsa4096/4EBF4D26A937DE4C
created: 2019-04-04 expires: 2019-04-05 usage: SC
trust: ultimate validity: ultimate
[ultimate] (1). someone@example.com
gpg> save
现在请注意,我们的密钥获得了签名能力。
$ gpg --homedir /tmp/gpg-change-usage -k
/tmp/gpg-change-usage/pubring.kbx
---------------------------------
pub rsa4096 2019-04-04 [SC] [expires: 2019-04-05]
987BE3D9CF90B1C912A165734EBF4D26A937DE4C
uid [ultimate] someone@example.com
而已!