注册会员 登录
编织人生论坛 返回首页

milkhq的个人空间 https://bbs.bianzhirensheng.com/?476402 [收藏] [复制] [RSS]

日志

gpg签名相关

已有 297 次阅读2015-3-31 16:16 |个人分类:work|系统分类:织女日记| gpg

1.创建密钥
gpg --gen-key

2.查看私钥
gpg -k

3.查看公钥
gpg --list-keys

4.导出公钥
gpg -o drivercenter.gpg -a --export drivercenter
(drivercenter为生成密钥时输入的name)

5.导出私钥
gpg -o drivercenter-private.gpg --export-secret-keys drivercenter

6.导入秘钥(公钥私钥都一样)
gpg --import filename

【公钥加密】
一个文件,我这里是加密cobbler.ks 这个文件,加密后是 cobbler.ks.gpg文件,需要私钥才能查看。
# gpg -o cobbler.ks.gpg -er chenshake cobbler.ks
gpg: 02B4038D: There is no assurance this key belongs to the named user

pub  2048R/02B4038D 2013-10-21 chenshake <shake.chen@gmail.com>
 Primary key fingerprint: B93B 05F8 9D63 5464 6DEE  6A08 EB9E D2BB AEAA 16F3
      Subkey fingerprint: FCCA 50DD C98D 644E 00FB  804C 4CD2 9544 02B4 038D

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

【私钥解密】

私钥查看 cobbler.ks.gpg
# gpg -o cobbler.ks -d cobbler.ks.gpg

You need a passphrase to unlock the secret key for
user: "chenshake <shake.chen@gmail.com>"
2048-bit RSA key, ID 02B4038D, created 2013-10-21 (main key ID AEAA16F3)

gpg: gpg-agent is not available in this session
gpg: encrypted with 2048-bit RSA key, ID 02B4038D, created 2013-10-21
      "chenshake <shake.chen@gmail.com>"

需要你输入你当初创建秘钥的时候设置的那个密码。这个时候,你就可以查看到加密的文件。

 


路过

鲜花

握手

雷人

评论 (0 个评论)

论坛地图|手机版|小黑屋|Archiver|颜色表|下载APP客户端|编织人生 ( ICP12028468-2 )

GMT+8, 2026-8-18 18:42

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部