首页 > 代码库 > GnuPG高级指导(4)加密分发我的私钥

GnuPG高级指导(4)加密分发我的私钥

 

私钥,需要绝密,绝对不让别人知道!

所以,分发私钥,可以加密一下!

 

 

1 给debian8加密一份“我的私钥”

 

opensuse13:~ #

opensuse13:~ #

opensuse13:~ # gpg -a -r "debian8" -o FranklinYang.rsa.sec.key.debian8.asc --encrypt FranklinYang.rsa.sec.key

gpg: C1845DA4: There is no assurance this key belongs to the named user

 

pub  2048g/C1845DA4 2016-11-25 debian8

 Primary key fingerprint: E6F5 0620 A8EA 0C60 FDBF  FD3E 1F8A 8A36 D04D 1A0B

      Subkey fingerprint: 36C6 7490 ABF8 0B12 7CE5  D788 A48C 4F81 C184 5DA4

 

It is NOT certain that the key belongs to the person named

in the user ID.  If you *really* know what you are doing,

you may answer the next question with yes.

 

Use this key anyway? (y/N) y

opensuse13:~ #

opensuse13:~ #

opensuse13:~ # l FranklinYang.rsa.sec.key.debian8.asc

-rw-r--r-- 1 root root 5994 Nov 25 23:41 FranklinYang.rsa.sec.key.debian8.asc

opensuse13:~ #

 

 

opensuse13:~ # scp FranklinYang.rsa.sec.key.debian8.asc franklin@192.168.19.132:/home/franklin/

franklin@192.168.19.132‘s password:

FranklinYang.rsa.sec.key.debian8.asc                100% 5994     5.9KB/s   00:00

opensuse13:~ #

opensuse13:~ #

 

 

root@debian8:~# l FranklinYang.rsa.sec.key.debian8.asc

-rw-r--r-- 1 franklin franklin 5994 Nov 25 23:45 FranklinYang.rsa.sec.key.debian8.asc

root@debian8:~#

 

 

2 给centos7加密一份“我的私钥”

 

opensuse13:~ #

opensuse13:~ # gpg -a -r "centos7" -o FranklinYang.rsa.sec.key.centos7.asc --encrypt FranklinYang.rsa.sec.key

gpg: CDA873F4: There is no assurance this key belongs to the named user

 

pub  2048g/CDA873F4 2016-11-25 centos7

 Primary key fingerprint: EEB2 90CA E690 2DD5 2480  FA72 9E1B 26EB 28D4 14A1

      Subkey fingerprint: 8997 4D45 4AB8 6F48 B0B6  322B B982 87D3 CDA8 73F4

 

It is NOT certain that the key belongs to the person named

in the user ID.  If you *really* know what you are doing,

you may answer the next question with yes.

 

Use this key anyway? (y/N) yes

opensuse13:~ #

opensuse13:~ # l FranklinYang.rsa.sec.key.centos7.asc

-rw-r--r-- 1 root root 5994 Nov 25 23:44 FranklinYang.rsa.sec.key.centos7.asc

opensuse13:~ #

opensuse13:~ #

opensuse13:~ #

opensuse13:~ # scp FranklinYang.rsa.sec.key.centos7.asc franklin@192.168.19.150:/home/franklin

franklin@192.168.19.150‘s password:

FranklinYang.rsa.sec.key.centos7.asc                        100% 5994     5.9KB/s   00:00

opensuse13:~ #

opensuse13:~ #

 

[root@centos7 ~]# ls -l FranklinYang.rsa.sec.key.centos7.asc

-rw-r--r--. 1 franklin franklin 5994 Nov 25 23:45 FranklinYang.rsa.sec.key.centos7.asc

[root@centos7 ~]#

 

 

 

3 在其他电脑上,解密“我的私钥”

 

 

root@debian8:~# gpg -d FranklinYang.rsa.sec.key.debian8.asc

 

You need a passphrase to unlock the secret key for

user: "debian8"

2048-bit ELG-E key, ID C1845DA4, created 2016-11-25 (main key ID D04D1A0B)

 

gpg: encrypted with 2048-bit ELG-E key, ID C1845DA4, created 2016-11-25

      "debian8"

-----BEGIN PGP PRIVATE KEY BLOCK-----

Version: GnuPG v2

 

lQIVBFg4PyYBEACTNyE3hnLtqHcGLQrjhh56yLtWiWJMxTeh26Xy378quxoGaLzC

JW9iOAq2AT67jdhYF6Lx7YE0YN1mPmzNhb8okhNdrP/wMxYHQB5mhxEeyLfPI6xG

HJ0gnDoHATmXteLTiWSxkPqQ+Byp9vIqTwDFMm7jMvQhO5DNLQrjmQIcnmo3hMZY

jOdyKYAPV3UpbcSWiO这可是我的私钥啊。。。pTRahQf6DlC3mO/c5+42NDFYgY0zX7haMLpLwc/Gn

dUDUdNvgFFWX9IhtnLf1VRFU0borjtBLaezDN5LaUYEkIK0UxRAOQRi6EDb//5Ar

uM/gOyZe0VK8cl9YFc1IZ28Rhkwr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D6x/5uFinU9tXDaluOZL4S1OP6kcsheF19Jf01GNLLFV8VCdhR2jtqT3bom1T8B

uxAFt4GjKDf1OEUfiK58nuUS/B3Ud7SpSJ4jIgcQ9nq6s46TtLs93hPKLp0gPy9D

DSLYhoJtFd6TZ9QRD08QR52QKd3rm50maqXQC9s0zhsOcvIut0Ze3yxlQp04tg0G

BSbRv8AB7TtPWWft1YKz065w2BLnCWUqc2WxHXRWIcir+vmtAGKdkHFqRpbNABAf

/Ikfc8jGyf+LtuoDTmyCRG7ZrQEQiRUwoy4B5ZOX4BjjQLwvle/L/swrrXkDdhpV

YojFtC0qiUmqbVLD0+/vw4x这可是我的私钥啊。。。2qvWUG23dQcHwXCMfb0H9St5+XgG108+MDm

tEovoMxl1B+vRb2VZh2rcRC7Lvo6r9Mbs7buOunBJQfqxC3y0AxHL5c6vHX6+7b3

fMIfI9L/jS2SC1+r888T4Hy4D2RyrB9kemsDFY7sM9ktq3aaXTUJLNPRdPyieOtx

N024vLR8llBVa3Joz29XBwhaGYViL01APQBDrVFsG/ziezxhgKiLFTAV6GQm2wdO

QpYTkQgbLEHYMk7CHpgfucCAIMEEI/m1ATmaEzcMQhEQoNiZ2mGjhlgXZBJwuSAg

4t3hh8jbsdFb2OCMbKzyib8pTQQ6H3cdQfEHV65ZSyj53L4XWonFLauxnwJVRRcj

PXTna3BzUqJvWkLz5pvDN/JP82/AjG9JWkXOmuBCx35lGGgDj0sqY49sb6c/npYZ

/3LJSI3rioane7qoz8Hqzow这可是我的私钥啊。。。GxjOtob7lWFow5vc3U3AcS4m9bSFaLwkkfNn78

rd6XYC6EqZmzY2uTv4gbBSvl9slW+bmsuEjHWHy12dagdok8JsxufJZcbaDblP78

iQIlBBgBAgAPBQJYOD8mAhsMBQkAxcEAAAoJEI2keVQnaFb3NKIP/jCs07cOx7Zs

bhO30vzpb1P3kaMzWHIVNN3H+HyGQaaUfF49J66TWQ5x8GKCVraqR14FBqHIJEh3

NkhgkdOMlFJQDbdpAfJoSAlNzc9aAoGZyHC9pp4MvEmUZx0GahkMSeVeGzy8m/JQ

wGNcJT3aidKk这可是我的私钥啊。。。SNZl7/zvJeAmvYwlGaUFkIXXnz1zb8CUi3wRf2m89a0N

gL7VWBk9rQp6BSGsjyz8kiRb8L7qDRUBXFjENLUcsFyk/JOX74iI5v6fLR68hhau

twdlKbl1A24wKX8AMFyPCVwacJ6n6/nVl/M/io/OOX04rZ76nyxDkslKNhSpt9Dy

hx2mlzBWcDbBoEtzl0evQdhWOkKCuaYCsUa80uaKzddBqg9Guw7Lc+3xRkKqWanM

MWDQVE/2iHdfZdGPSt1+U5fvNn2xP648

=p/mc

-----END PGP PRIVATE KEY BLOCK-----

root@debian8:~#

 

 

root@debian8:~# gpg -a -o FranklinYang.sec.key -d FranklinYang.rsa.sec.key.debian8.asc

 

You need a passphrase to unlock the secret key for

user: "debian8"

2048-bit ELG-E key, ID C1845DA4, created 2016-11-25 (main key ID D04D1A0B)

 

gpg: encrypted with 2048-bit ELG-E key, ID C1845DA4, created 2016-11-25

      "debian8"

root@debian8:~#

root@debian8:~#

root@debian8:~# l FranklinYang.sec.key

-rw-r--r-- 1 root root 4942 Nov 25 23:52 FranklinYang.sec.key

root@debian8:~#

root@debian8:~#

 

这就是“我的”私钥!

 

 

 

[root@centos7 ~]#

[root@centos7 ~]# gpg -a -d FranklinYang.rsa.sec.key.centos7.asc

 

You need a passphrase to unlock the secret key for

user: "centos7"

2048-bit ELG key, ID CDA873F4, created 2016-11-25 (main key ID 28D414A1)

 

gpg: encrypted with 2048-bit ELG key, ID CDA873F4, created 2016-11-25

      "centos7"

-----BEGIN PGP PRIVATE KEY BLOCK-----

Version: GnuPG v2

 

lQIVBFg4PyYBEACTNyE3hnLtqHcGLQrjhh56yLtWiWJMxTeh26Xy378quxoGaLzC

JW9iOAq2AT67jdhYF6Lx7YE0YN1mPmzNhb8okhNdrP/wMxYHQB5mhxEeyLfPI6xG

HJ0gnDoHATmXteLTiWSxkPqQ+Byp9vIqTwDFM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HTDta3WSmT41AXiUBW4N1raGC1RmB

QiPpWhesFyWFOuCH1pw/0i21OxHZFNypnSRSqYd8oagIijXdCgD7/EZdAV8IKhjP

bLqmFnLfEiwy4rMzsxkghf/OtIcrt73TFhuXCgnnla8ukAhh7giEoO8AfBvyyakS

7XTPjGZokeF7ak/xeYrP这可是我的私钥啊。。。By9HXInOk7x5Xy0EvAyqRdzf3pOC66RkfdEN3om

Hjj/COMbk6PIkLkWLfROXE7QnAwXu5AjxucAcKNHjxcr/bUJAlyKE81hcOea13VW

KjD5Ww8cQvinNyUJevZt//6R010AwUNX96JKgb5bhpg1kp9qQGV4XeWgNahtTYkw

wUdCgwiu5S7zSQARAQAB/gMDAr27jk6nvmsq7nl6KrCV6q1KnBs5b0ozYMnUoZpm

mEhqFQ0AVCDxYOkSnTgHIPQRi9tPUnATuK//iqoBjTwQ1ufbg85OdnY57Gq4aVT0

IJsZcwgcGeWZf0gRN7DBxf2kVl8HhC+FyQ14+lDHN0OrxMKYttH1xpA50qnV9qUr

+fcae+nNSm1D9KyYRRGARByg/aGpCDr8ed27YY6ZtQYd+v2Xwm/PByl7o2VER4Sb

iGnw5Ezti4VWptWCuVLq这可是我的私钥啊。。。Uwoy4B5ZOX4BjjQLwvle/L/swrrXkDdhpV

YojFtC0qiUmqbVLD0+/vw4xE4usQJxL7DdHKdzkWx/5sv89fK9fApRgRPt+Q6a9i

x+ZUyGdsT8iEmAYBHNYyORSKEQIbG7VDtFMrPCk38mykgsAElMyTOHe/258uvpSr

BDATnqHdKE4fEFSquYfjDeEZtWF6XGS5XAe/xHXQPbElWHesaNx/miRe5nd4ySVl

h270DT5ALO11eGiKkiMD4SPEzrZX7QEstJdDjdFWHVfGVINMiVM9wwJ5+oKqlPD6

TAoBq5+clOcR0/3YxxJaGCun1wGj2CE9arLhrJfQbrW6UQB/FP+l8dcmh1a365Uc

rln1nKaVyeROap8VOQNWqR0FzhkXd2qvWUG23dQcHwXCMfb0H9St5+XgG108+MDm

tEovoMxl1B+vRb2VZh2rc这可是我的私钥啊。。。aGYViL01APQBDrVFsG/ziezxhgKiLFTAV6GQm2wdO

QpYTkQgbLEHYMk7CHpgfucCAIMEEI/m1ATmaEzcMQhEQoNiZ2mGjhlgXZBJwuSAg

4t3hh8jbsdFb2OCMbKzyib8pTQQ6H3cdQfEHV65ZSyj53L4XWonFLauxnwJVRRcj

PXTna3BzUqJvWkLz5pvDN/JP82/AjG9JWkXOmuBCx35lGGgDj0sqY49sb6c/npYZ

/3LJSI3rioane7qoz8Hqzowax这可是我的私钥啊。。。04fkEmQgztnA0MoC//2Z6D9EUXV1qK89k4gs

fSLA6IB77cxHsEKcwTSHpKLaSWGxjOtob7lWFow5vc3U3AcS4m9bSFaLwkkfNn78

rd6XYC6EqZmzY2uTv4gbBSvl9slW+bmsuEjHWHy12dagdok8JsxufJZcbaDblP78

iQIlBBgBAgAPBQJYOD8mAhsMBQkAxcEAAAoJEI2keVQnaFb3NKIP/jCs07cOx7Zs

bhO30vzpb1P3kaMzWHIVNN3H+HyGQaaUfF49J66TWQ5x8GKCVraqR14FBqHIJEh3

NkhgkdOMlFJQDbdpAfJoSAlNzc9aAoGZyHC9pp4MvEmUZx0GahkMSeVeGzy8m/JQ

wGNcJT3aidKkz0DPg8ifbw1u4gFKIJlQ/6QSodWdwoeqnbhNFWxHNuQEzXkLSkuv

SwaVduHihCBWWxB39Q这可是我的私钥啊。。。qMQ2NGaSbvwqwKVNvOnHzCz40DTW6QFG2ZHO

3JJjrZfiVQ1oSLXMoqdKSNZl7/zvJeAmvYwlGaUFkIXXnz1zb8CUi3wRf2m89a0N

gL7VWBk9rQp6BSGsjyz8kiRb8L7qDRUBXFjENLUcsFyk/JOX74iI5v6fLR68hhau

twdlKbl1A24wKX8AMFyPCVwacJ6n6/nVl/M/io/OOX04rZ76nyxDkslKNhSpt9Dy

hx2mlzBWcDbBoEtzl0evQdhWOkKCuaYCsUa80uaKzddBqg9Guw7Lc+3xRkKqWanM

MWDQVE/2iHdfZdGPSt1+U5fvNn2xP648

=p/mc

-----END PGP PRIVATE KEY BLOCK-----

[root@centos7 ~]#

[root@centos7 ~]#

[root@centos7 ~]#

[root@centos7 ~]# gpg -a -o FranklinYang.sec.key -d FranklinYang.rsa.sec.key.centos7.asc

 

You need a passphrase to unlock the secret key for

user: "centos7"

2048-bit ELG key, ID CDA873F4, created 2016-11-25 (main key ID 28D414A1)

 

gpg: encrypted with 2048-bit ELG key, ID CDA873F4, created 2016-11-25

      "centos7"

[root@centos7 ~]#

[root@centos7 ~]# ls -l FranklinYang.sec.key

-rw-r--r--. 1 root root 4942 Nov 25 23:51 FranklinYang.sec.key

[root@centos7 ~]#

[root@centos7 ~]#

[root@centos7 ~]#

 

 

 

4 在其他电脑上,导入“我的私钥”

 

root@debian8:~#

root@debian8:~# gpg --import FranklinYang.sec.key

gpg: key 276856F7: secret key imported

gpg: key 276856F7: "FranklinYang (Encrypt RSA 4096) <andypeker@163.com>" not changed

gpg: Total number processed: 1

gpg:              unchanged: 1

gpg:       secret keys read: 1

gpg:   secret keys imported: 1

root@debian8:~#

root@debian8:~#

root@debian8:~# gpg -K

/root/.gnupg/secring.gpg

------------------------

sec  1024D/D04D1A0B 2016-11-25 [expires: 2016-12-09]

uid                  debian8

ssb   2048g/C1845DA4 2016-11-25

 

sec  4096R/276856F7 2016-11-25 [expires: 2017-04-24]

uid                  FranklinYang (Encrypt RSA 4096) <andypeker@163.com>

ssb   4096R/0A09DAC9 2016-11-25

 

root@debian8:~#

root@debian8:~#

root@debian8:~# gpg -k

/root/.gnupg/pubring.gpg

------------------------

pub   4096R/276856F7 2016-11-25 [expires: 2017-04-24]

uid                  FranklinYang (Encrypt RSA 4096) <andypeker@163.com>

sub   4096R/0A09DAC9 2016-11-25 [expires: 2017-04-24]

 

pub   1024D/D04D1A0B 2016-11-25 [expires: 2016-12-09]

uid                  debian8

sub   2048g/C1845DA4 2016-11-25 [expires: 2016-12-09]

 

root@debian8:~#

 

 

 

[root@centos7 ~]#

[root@centos7 ~]# gpg --import FranklinYang.sec.key

gpg: key 276856F7: secret key imported

gpg: key 276856F7: "FranklinYang (Encrypt RSA 4096) <andypeker@163.com>" not changed

gpg: Total number processed: 1

gpg:              unchanged: 1

gpg:       secret keys read: 1

gpg:   secret keys imported: 1

[root@centos7 ~]#

[root@centos7 ~]#

[root@centos7 ~]# gpg -K

gpg: checking the trustdb

gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model

gpg: depth: 0  valid:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u

gpg: next trustdb check due at 2016-12-09

/root/.gnupg/secring.gpg

------------------------

sec  1024D/28D414A1 2016-11-25 [expires: 2016-12-09]

uid                  centos7

ssb   2048g/CDA873F4 2016-11-25

 

sec  4096R/276856F7 2016-11-25 [expires: 2017-04-24]

uid                  FranklinYang (Encrypt RSA 4096) <andypeker@163.com>

ssb   4096R/0A09DAC9 2016-11-25

 

[root@centos7 ~]#

[root@centos7 ~]# gpg -k

/root/.gnupg/pubring.gpg

------------------------

pub   4096R/276856F7 2016-11-25 [expires: 2017-04-24]

uid                  FranklinYang (Encrypt RSA 4096) <andypeker@163.com>

sub   4096R/0A09DAC9 2016-11-25 [expires: 2017-04-24]

 

pub   1024D/28D414A1 2016-11-25 [expires: 2016-12-09]

uid                  centos7

sub   2048g/CDA873F4 2016-11-25 [expires: 2016-12-09]

 

[root@centos7 ~]#

GnuPG高级指导(4)加密分发我的私钥