一、GPG简介
GNU Privacy Guard(GnuPG或GPG)是一种加密软件,它是PGP加密软件的满足GPL的替代物。GnuPG依照由IETF订定的OpenPGP技术标准设计。GnuPG用于加密、数字签名及产生非对称钥匙对的软件。
二、安装配置
1:加密初始
0 $ gpg --gen-key #生成密钥对
2:密码信息
01234567891011 gpg: /root/.gnupg/trustdb.gpg: trustdb createdgpg: key 5593FD3C marked as ultimately trustedpublic and secret key created and signed.gpg: checking the trustdbgpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust modelgpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1ugpg: next trustdb check due at 2021-02-12pub 4096R/5593FD3C 2019-02-13 [expires: 2021-02-12]Key fingerprint = E4E7 63CF D688 B7EB 8C7D 4D2E 6085 9163 5593 FD3Cuid IByrd (message) <root@t4x.org>sub 4096R/B5DFE87F 2019-02-13 [expires: 2021-02-12]
3:列出秘钥
01234567891011 $ gpg --list-keys #gpg -k/root/.gnupg/pubring.gpg------------------------pub 4096R/5593FD3C 2019-02-13 [expires: 2021-02-12]uid IByrd (message) <root@t4x.org>sub 4096R/B5DFE87F 2019-02-13 [expires: 2021-02-12]$ gpg --list-secret-keys #列出私钥/root/.gnupg/secring.gpg------------------------sec 4096R/5593FD3C 2019-02-13 [expires: 2021-02-12]uid IByrd (message) <root@t4x.org>ssb 4096R/B5DFE87F 2019-02-13
4:公钥导出
012 $ gpg -a --export IByrd > IByrd.txt$ gpg --export --armor 5593FD3C -o file.key > 1.txt$ gpg --armor --output public-key-gmail.txt --export 5593FD3C
5:秘钥导出
01 $ gpg -a --export-secret-keys 5593FD3C > secret.txt$ gpg --armor --output secret-key-gmail.txt --export-secret-keys 5593FD3C
6:文件加密
0123 $ echo "aaaaa" > file.txt$ gpg --encrypt --armor -r 5593FD3C file.txt #默认生成 file.txt.asc$ gpg --recipient 5593FD3C --output file.txt.gpg --encrypt file.txt #gpg --recipient IByrd --output file.txt.gpg1 --encrypt file.txt$ gpg -e -r IByrd file.txt #默认生成 file.txt.gpg
7:文件解密
01234 $ gpg --decrypt file.txt.asc$ gpg -o ab.txt -d file.txt.gpg$ gpg --local-user IByrd --output 1.log --decrypt file.txt.gpg$ echo "admin123" | gpg --batch --passphrase-fd 0 --output aaaa.log --decrypt file.txt.gpg$ gpg --passphrase=IByrd -q --no-tty -d file.txt.gpg
8:导入私钥
SourceByrd's Weblog-https://note.t4x.org/basic/gnu-privacy-guard/
0 $ gpg --import secret-key-gmail.txt
三、问题解答
SourceByrd's Weblog-https://note.t4x.org/basic/gnu-privacy-guard/SourceByrd's Weblog-https://note.t4x.org/basic/gnu-privacy-guard/
0123 We need to generate a lot of random bytes. It is a good idea to performsome other action (type on the keyboard, move the mouse, utilize thedisks) during the prime generation; this gives the random numbergenerator a better chance to gain enough entropy.
1、解决方法:
SourceByrd's Weblog-https://note.t4x.org/basic/gnu-privacy-guard/
01 $ yum -y install rng-tools$ rngd -r /dev/urandom
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!