gpg2 生成秘钥redis
查看是否安装
rpm-qa│grep gnupgcentos
rpm –ivh gnupg2-2.0.10-6.el5服务器
gpg2 --gen-key
[root@VM_0_178_centos .ssh]# gpg2 --gen-key
gpg (GnuPG) 2.0.14; Copyright (C) 2009 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.ssh
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?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
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)
Key does not expire at all
Is this correct? (y/N)
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y ###前面都缺省就行,这样选择yeside
GnuPG needs to construct a user ID to identify your key.ui
Real name: VM_0_178_centos ###这里输入id,得记住,后面得用到
Email address: ***@qq.com
Comment: 123
You selected this USER-ID:
"VM_0_178_centos (123) <***@qq.com>" this
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.
输入两次密码肯定以后(密码得记住,解密的时候须要用到),就是慢慢的等待吧,能够去玩会儿加密
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 2048R/BFFDD071 2016-11-21
Key fingerprint = 4A27 CB17 83BF 6938 93E3 C05B 0466 A968 BFFD D071
uid VM_0_178_centos (123) <***@qq.com>
sub 2048R/263FFE44 2016-11-21spa
生成成功
gpg2 -k|K 小写查看全部已导出的公钥
###导出公钥,这里-a 后面接的是id,也就是建立的时候输入的real name
gpg2 --export -a VM_0_178_centos > test.keyci
###而后把下载把公钥给服务方加密文件就行
加密文件
先把前面的公钥上传,而后倒入此服务器
gpg2 --import test.key
开始加密文件
gpg2 -e -r USERID -o /tmp/xxx $FILE
/tmp/xxx为输出文件的路径;$FILE为须要加密的文件;USERID可经过gpg2 –k来查看。为红框显示部分。
解密 gpg2 –d --batch --passphrase 密码 –o /tmp/xxx $FILE 此处密码为以前生成key时输入的密码;/tmp/xxx为输出文件的路径;$FILE为须要解密的文件;