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爲須要解密的文件;