[[email protected] ~]$ gpg --gen-key
gpg (GnuPG) 2.0.22; Copyright (C) 2013 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.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
2.询问密钥对位数,默认为2048,本例中手动输入1024.
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 1024
提示输入密钥对有效期,输入“0”(永不过期)并按回车键确定。
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 0
提示将永不过期,输入“y”确认。
Key does not expire at all
Is this correct? (y/N) y
输入密钥对名称(本例中为cheshi)。
GnuPG needs to construct a user ID to identify your key.
Real name: cheshi
依次输入邮件地址和备注。
Real name: cheshi
Email address: [email protected]
Comment: NA
You selected this USER-ID:
"cheshi (NA) <[email protected]>"
询问是否修改或者确认,直接输入“o”确认。
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
提示您需要设置私钥。
Linux下使用GPG(GnuPG)加密及解密文件
再次输入私钥。
Linux下使用GPG(GnuPG)加密及解密文件
系统需要时间生成密钥对,期间最好随机输入字符或移动鼠标等,有助于生成密钥对,结果如下图。
You need a Passphrase to protect your secret key.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: key 70E8A292 marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 1024R/70E8A292 2019-06-05
Key fingerprint = C54E 7282 49B7 51E8 00BB DCFA B8BD F821 70E8 A292
uid cheshi (NA) <[email protected]>
sub 1024R/26A8DC48 2019-06-05
[[email protected] ~]$ gpg --decrypt 123455.gpg > 123455
You need a passphrase to unlock the secret key for
user: "cheshi (NA) <[email protected]>"
1024-bit RSA key, ID 26A8DC48, created 2019-06-05 (main key ID 70E8A292)
gpg: encrypted with 1024-bit RSA key, ID 26A8DC48, created 2019-06-05
"cheshi (NA) <[email protected]>"
[[email protected] 模板]$ gpg --delete-secret-keys cheshi
gpg (GnuPG) 2.0.22; Copyright (C) 2013 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.
sec 1024R/70E8A292 2019-06-05 cheshi (NA) <[email protected]>
要从钥匙环里删除这把密钥吗?(y/N)y
这是一把私钥!――真的要删除吗?(y/N)y
继续输入“gpg --delete-keys cheshi”卸载公钥。
[[email protected] 模板]$ gpg --delete-keys cheshi
gpg (GnuPG) 2.0.22; Copyright (C) 2013 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.
pub 1024R/70E8A292 2019-06-05 cheshi (NA) <[email protected]>
要从钥匙环里删除这把密钥吗?(y/N)y