如何通过 GPG(GnuPG) 中的子密钥(多个子密钥(e))加密
HOW to encrypt by a subkey(multiple subkey(e)) in GPG(GnuPG)
如何在 GPG(GnuPG) 中通过子密钥(多个子密钥(e))加密
pub rsa4096/22E49AB870AD169A 2017-03-09 [SC]
uid [ultimate] Jack Wonda <wangjievibeke@foxmail.com>
uid [ultimate] 王杰 <jack20130107@qq.com>
sub rsa4096/D39A707D61F13A26 2017-03-09 [E] [expires: 2020-04-25]
sub rsa4096/11FAB3E82F75B202 2017-04-24 [S] [expires: 2019-04-24]
sub rsa4096/B305BA41FD1F7793 2017-04-26 [E] [expires: 2019-04-26]
我有两个子密钥用于加密,但目前我只能使用最后一个子密钥(B305BA41FD1F7793)。
例如:
gpg2 -r D39A707D61F13A26 -e doc
File 'doc.gpg' exists. Overwrite? (y/N) y
gpg2 -d doc.gpg
gpg: encrypted with 4096-bit RSA key, ID B305BA41FD1F7793, created 2017-04-26
"Jack Wonda <wangjievibeke@foxmail.com>"
123456
即使我指定了第一个子项,它仍然会转到最后一个。
您可以通过在其 ID 后附加感叹号来强制 gpg 使用特定密钥。在你的情况下:
gpg2 -r 0xD39A707D61F13A26! -e doc
您甚至可以要求 gpg 使用 两个 密钥进行加密(这样您就可以使用关联的 public 密钥之一进行解密):
gpg2 -r 0xD39A707D61F13A26! -r 0xB305BA41FD1F7793! -e doc
根据我的 Arch 系统上安装的联机帮助页(奇怪的是,我在其他地方找不到具有相同信息的相同版本):
HOW TO SPECIFY A USER ID
There are different ways to specify a user ID to GnuPG. Some of them
are only valid for gpg others are only good for gpgsm. Here is the
entire list of ways to specify a key:
By key Id.
This format is deduced from the length of the string and its
content or 0x prefix. The key Id of an X.509 certificate are the
low 64 bits of its SHA-1 fingerprint. The use of key Ids is
just a shortcut, for all automated processing the fingerprint
should be used.
When using gpg an exclamation mark (!) may be appended to force
using the specified primary or secondary key and not to try and
calculate which primary or secondary key to use.
The last four lines of the example give the key ID in their long
form as internally used by the OpenPGP protocol. You can see the
long key ID using the option --with-colons.
如何在 GPG(GnuPG) 中通过子密钥(多个子密钥(e))加密
pub rsa4096/22E49AB870AD169A 2017-03-09 [SC]
uid [ultimate] Jack Wonda <wangjievibeke@foxmail.com>
uid [ultimate] 王杰 <jack20130107@qq.com>
sub rsa4096/D39A707D61F13A26 2017-03-09 [E] [expires: 2020-04-25]
sub rsa4096/11FAB3E82F75B202 2017-04-24 [S] [expires: 2019-04-24]
sub rsa4096/B305BA41FD1F7793 2017-04-26 [E] [expires: 2019-04-26]
我有两个子密钥用于加密,但目前我只能使用最后一个子密钥(B305BA41FD1F7793)。
例如:
gpg2 -r D39A707D61F13A26 -e doc
File 'doc.gpg' exists. Overwrite? (y/N) y
gpg2 -d doc.gpg
gpg: encrypted with 4096-bit RSA key, ID B305BA41FD1F7793, created 2017-04-26
"Jack Wonda <wangjievibeke@foxmail.com>"
123456
即使我指定了第一个子项,它仍然会转到最后一个。
您可以通过在其 ID 后附加感叹号来强制 gpg 使用特定密钥。在你的情况下:
gpg2 -r 0xD39A707D61F13A26! -e doc
您甚至可以要求 gpg 使用 两个 密钥进行加密(这样您就可以使用关联的 public 密钥之一进行解密):
gpg2 -r 0xD39A707D61F13A26! -r 0xB305BA41FD1F7793! -e doc
根据我的 Arch 系统上安装的联机帮助页(奇怪的是,我在其他地方找不到具有相同信息的相同版本):
HOW TO SPECIFY A USER ID
There are different ways to specify a user ID to GnuPG. Some of them are only valid for gpg others are only good for gpgsm. Here is the entire list of ways to specify a key:
By key Id. This format is deduced from the length of the string and its content or 0x prefix. The key Id of an X.509 certificate are the low 64 bits of its SHA-1 fingerprint. The use of key Ids is just a shortcut, for all automated processing the fingerprint should be used. When using gpg an exclamation mark (!) may be appended to force using the specified primary or secondary key and not to try and calculate which primary or secondary key to use. The last four lines of the example give the key ID in their long form as internally used by the OpenPGP protocol. You can see the long key ID using the option --with-colons.