如何使用GPG创建,列出密钥和签名文件?

GnuPG or GPG is Gnu version of Open PG standard implementation. It is very popular especially at personal use for mails etc. Here I will look basic usage of gpg2 in Linux command line interface. gpg2 is the second major version of gpg.

GnuPG或GPG是Open PG标准实现的Gnu版本。 它非常流行,尤其是在个人用于邮件等方面。在这里,我将介绍Linux命令行界面中gpg2的基本用法。 gpg2是gpg的第二个主要版本。

创建/生成私密GPG密钥 (Create/Generate Private GPG Keys)

Here we will create public and private keys for key-ring. Required information asked while certificate generation process. Real name and Email address is given by user and then to encrypt these public and private keys and password is created

在这里,我们将为密钥环创建公用密钥和专用密钥。 证书生成过程中询问的必需信息。 用户提供真实姓名和电子邮件地址,然后对这些公钥和私钥进行加密,并创建密码

$ gpg2 --key-gen
Create/Generate Private GPG Keys
Create/Generate Private GPG Keys
创建/生成私密GPG密钥

During generation of the GPG Private Keys we will be asked for Real Name and Email . After providing this information we will need to enter a passphrase which will be used to encrypt our GPG Private Key. Generation of the private key requires some randomness which may take some time according to the situation. After keys are generated their serial number are provided.

在生成GPG私钥的过程中,我们将要求您提供Real NameEmail 。 提供此信息后,我们需要输入密码,该密码将用于加密我们的GPG私钥。 私钥的生成需要一定的随机性,根据情况可能会花费一些时间。 生成密钥后,将提供其序列号。

列出现有的PGP密钥 (List Existing PGP Keys)

It can be auto completed by using tab as you can see in first command. In the second command we list existing public keys in keyring. We will provide --list-key option like below.

如您在第一个命令中所见,可以通过使用制表符来自动完成该操作。 在第二个命令中,我们列出了密钥环中现有的公共密钥。 我们将提供--list-key选项,如下所示。

$ gpg2 --list-key
List Existing PGP Keys
List Existing PGP Keys
列出现有的PGP密钥

We can see that keys are stored in the user home directory .gnupg directory. Some information like Valid etc also provided during the listing of the keys.

我们可以看到密钥存储在用户主目录.gnupg目录中。 在列出密钥期间还提供了诸如Valid等的一些信息。

签名PGP密钥 (Sign PGP Key)

To sign the data with the specific key not default. Here the --default-key parameter is looked in keyring in fingerprint, name, email etc. If you want signature apart from data use -b option. We will provide İsmail as default key with the --default-key option. We will also provide the data with the -s option.

使用特定密钥签名数据不是默认值。 在此,-- --default-key参数在指纹,名称,电子邮件等的密钥环中查找。如果要数据以外的签名,请使用-b选项。 我们将提供İsmail作为默认密钥以及--default-key选项。 我们还将为数据提供-s选项。

$ gpg2 --default-key İsmail -s test
Sign PGP Key
Sign PGP Key
签名PGP密钥
GPG Passphrase
GPG Passphrase
GPG密码

We will also asked for passphrase to decrypt and use our private key which is create in the previous step.

我们还将要求密码解密并使用在上一步中创建的私钥

LEARN MORE  chage Command Tutorial With Examples To Manage User Accounts In Linux
了解更多chage命令教程,以及在Linux中管理用户帐户的示例

列出秘密钥匙(List Secret Keys)

To see private keys and  related info like fingerprint. We will use --list-secret-keys  option for this.

查看私钥和相关信息,例如指纹。 我们将为此使用--list-secret-keys选项。

$ gpg2 --list-secret-keys
List Secret Keys
List Secret Keys
列出秘密钥匙

验证签名的PGP文件(Verify Signed PGP File)

The main usage aim of PGP is verifying file whether they are signed accordingly. We can use --verify option by providing the file name. We will verify the gpg file named data.gpg.

PGP的主要用途是验证文件是否已相应签名。 我们可以通过提供文件名来使用--verify选项。 我们将验证名为data.gpg的gpg文件。

$ gpg2 --verify data.gpg
Verify Signed PGP File
Verify Signed PGP File
验证签名的PGP文件

导出键(Export Keys)

Some time we may need to use existing key in different systems. We have to export these keys into a file. To export existing keyring and use in other systems. We will export existing keys into file name mykeys

有时我们可能需要在不同系统中使用现有密钥。 我们必须将这些密钥导出到文件中。 导出现有密钥环并在其他系统中使用。 我们将现有密钥导出到文件名mykeys

$ gpg2 --export > mykeys
Export Keys
Export Keys
导出键

如何使用GPG创建,列出密钥和签名文件? 信息图 (How To Use GPG To Create, List Keys and Sign Files? Infographic)

How To Use GPG To Create, List Keys and Sign Files? Infographic
How To Use GPG To Create, List Keys and Sign Files? Infographic
如何使用GPG创建,列出密钥和签名文件? 信息图

翻译自: https://www.poftut.com/how-to-use-gpg-to-create-list-keys-and-sign-files/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值