GnuPG高级指导(1)GnuPG的用法

1       k与K

可以参考man gpg里的说明:

-k

--list-public-keys

List  all  keys from the public keyrings, or just the keys given

on the command line.

Avoid using the output of this command in scripts or other  pro-

grams  as  it  is likely to change as GnuPG changes. See --with-

colons for a  machine-parseable  key  listing  command  that  is

appropriate for use in scripts and other programs.

--list-secret-keys

-K     List  all  keys from the secret keyrings, or just the ones given

on the command line. A # after the letters sec  means  that  the

secret  key  is  not  usable (for example, if it was created via

--export-secret-subkeys).

2 生成密钥

opensuse13:~ #

opensuse13:~ # gpg -K

opensuse13:~ # gpg -k

opensuse13:~ # gpg --gen-key

gpg (GnuPG) 2.0.26; 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?

RSA keys may be between 1024 and 4096 bits long.

What keysize do you want? (2048) 4096

Requested keysize is 4096 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) 5m

Key expires at Mon Apr 24 21:17:17 2017 CST

Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: FranklinYang

Email address: [email protected]

Comment: Encrypt RSA 4096

You selected this USER-ID:

"FranklinYang (Encrypt RSA 4096) <[email protected]>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O

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 F55B4065 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

gpg: next trustdb check due at 2017-04-24

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

Key fingerprint = 13A2 DD5C 4BB1 13DA 9665  D49B 2055 C017 F55B 4065

uid       [ultimate] FranklinYang (Encrypt RSA 4096) <[email protected]>

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

opensuse13:~ #

opensuse13:~ #

opensuse13:~ #

opensuse13:~ # gpg -k

/root/.gnupg/pubring.gpg

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

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

uid       [ultimate] FranklinYang (Encrypt RSA 4096) <[email protected]>

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

opensuse13:~ # gpg -K

/root/.gnupg/secring.gpg

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

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

uid                  FranklinYang (Encrypt RSA 4096) <[email protected]>

ssb   4096R/0A09DAC9 2016-11-25

opensuse13:~ #

opensuse13:~ #

3 公钥和私钥的区别

注意下面这个几个key:

pub sub sec ssb

各有用途!

比如下面:

opensuse13b:~ #

opensuse13b:~ # gpg -K

/root/.gnupg/secring.gpg

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

sec   4096R/9DDE7116 2016-11-24 [expires: 2017-05-24]

uid                  suse13b RSA encrypt

ssb   4096R/EC3B4291 2016-11-24

sec#  2048R/6EB6C991 2016-11-24 [expires: 2017-02-22]

uid                  virtual RSA Encrypt <[email protected]>

ssb   2048g/E423A188 2016-11-28

sec   2048R/EBD97E5C 2016-11-28

uid                  macOSwhyang

ssb   2048R/8EDFDBEC 2016-11-28

ssb   2048g/45FFDAC5 2016-11-28

ssb   2048D/C1CAA280 2016-11-28

opensuse13b:~ #

opensuse13b:~ #

时间: 2024-08-10 17:09:33

GnuPG高级指导(1)GnuPG的用法的相关文章

GnuPG高级指导(2)上传/导出分发公钥

1 上传到keyserver opensuse13:~ # gpg -k /root/.gnupg/pubring.gpg ------------------------ pub   4096R/276856F7 2016-11-25 [expires: 2017-04-24] uid       [ultimate] FranklinYang (Encrypt RSA 4096) <[email protected]> sub   4096R/0A09DAC9 2016-11-25 [ex

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 belo

GnuPG高级指导(3)导出私钥

1 为什么要导出分发私钥 友情提示:分发私钥,是危险的! 我有好几个电脑,只想用一对密钥:也就是说我需要把我的私钥,放到那几个电脑上.这样,我就就可以在任意电脑上,解密和签名以及其他. 1       怎么做 使用(临时)公钥把私钥加密,然后传到我的其他某个电脑,再解密. 3 我的debian8,生成(临时)密钥 [email protected]:~# gpg -K [email protected]:~# gpg -k /root/.gnupg/pubring.gpg -----------

GnuPG高级指导(5)分发我的私钥(+签名)

(加密 + 签名,保证私钥的安全) 1 给debian8加密(再IDEA加密)并签名一份“我的私钥” opensuse13:~ # opensuse13:~ # opensuse13:~ # gpg -r "debian8" -o FranklinYang.rsa.sec.key.sign.debian8.asc -a --se --cipher-algo IDEA FranklinYang.rsa.sec.key You need a passphrase to unlock the

GnuPG高级指导(6)在其他电脑上启用“我的密钥”

1 其他电脑上的密钥 [email protected]:~# 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-0

PHP高级特性一之正则表达式用法

在PHP中,我们进行字符串处理时,能用字符串处理函数时我们当然要使用简单的字符串处理函数,但字符串处理函数的能力是有限的,所以我们就需要利用一个更强大的工具,那就是正则表达式. 简述正则表达式 正则表达式是什么? 正则表达式就是描述字符串排列模式的一种自定义语法规则.正则表达式就是通过构建具有特定规则的模式,和输入字符串信息进行比较,然后进行分割.匹配.查找.替换等等的相关操作.正则表达式不是PHP中独有的,多种语言均可以使用正则表达式,在这里我们介绍正则在PHP中的用法. 使用场合 1. PH

GnuPG

GNUPG 一GUNPG简介 GnuPG(GNU Privacy Guard或GPG)是一个以GNU通用公共许可证释出的开放源码用于加密或签名的软件,可用来取代PGP. 非对称加密方式,简单理解就是用公钥加密文件,用私钥解密文件.如果你需要发送加密信息,首先获取接收者的公钥,然后利用该公钥加密后传递,对方利用对应的私钥就可解密.也就是说,公钥是锁,私钥是钥匙.非对称加密方式很好地解决了传递机密信息的问题. GPG,又称为 GnuPG,全称是 Gnu Private Guard,即 GNU 隐私卫

使用GnuPG进行数据加密

一:安装GnuPG wget ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-2.1.1.tar.bz2     tar xf gnupg-2.1.1.tar.bz2 ./configure --prefix=/usr/local/gnupg && make && make check && make install 此处报错了 是因为缺少相应的组件 下载下来安装上就ok ftp://ftp.gnupg.org/gcrypt/l

Jsoup代码解读之四-parser

Jsoup代码解读之四-parser 作为Java世界最好的HTML 解析库,Jsoup的parser实现非常具有代表性.这部分也是Jsoup最复杂的部分,需要一些数据结构.状态机乃至编译器的知识.好在HTML语法不复杂,解析只是到DOM树为止,所以作为编译器入门倒是挺合适的.这一块不要指望囫囵吞枣,我们还是泡一杯咖啡,细细品味其中的奥妙吧. 基础知识 编译器 将计算机语言转化为另一种计算机语言(通常是更底层的语言,例如机器码.汇编.或者JVM字节码)的过程就叫做编译(compile).编译器(