成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

linux:GPG加密和解密

安全 數(shù)據(jù)安全
GPG就是用來加密數(shù)據(jù)與制作證書的一套工具,它是一個(gè)完全免費(fèi)、源代碼公開,并且與PGP完全兼容的軟件產(chǎn)品。GPG軟件作為用于加密和數(shù)字簽名的開放源碼工具,許多Linux發(fā)行版本都自帶了該軟件。

隨著網(wǎng)絡(luò)與計(jì)算機(jī)技術(shù)的發(fā)展,數(shù)據(jù)存儲與數(shù)據(jù)交換的安全性已經(jīng)變得越來越重要,加密技術(shù)已經(jīng)很早就用于數(shù)據(jù)存儲和數(shù)據(jù)交換。為了確保網(wǎng)絡(luò)數(shù)據(jù)交換時(shí)的雙方身份的正確性,簽證體系也已經(jīng)成熟。GPG就是用來加密數(shù)據(jù)與制作證書的一套工具,它是一個(gè)完全免費(fèi)、源代碼公開,并且與PGP完全兼容的軟件產(chǎn)品。GPG軟件作為用于加密和數(shù)字簽名的開放源碼工具,許多Linux發(fā)行版本都自帶了該軟件。

[[130530]]

下面,讓我們一起來看看,gpg如何加密和解密的吧。

創(chuàng)建密鑰

gpg --gen-key

你要求輸入一下內(nèi)容,這些內(nèi)容,基本英文,還是很好明白

root@g140:~# gpg --gen-key
gpg (GnuPG) 1.4.11; Copyright (C) 2010 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.
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
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
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) "
Real name: chenshake
Email address: shake.chen@gmail.com
Comment:
You selected this USER-ID:
"chenshake "
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.
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key AEAA16F3 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
pub 2048R/AEAA16F3 2013-10-21
Key fingerprint = B93B 05F8 9D63 5464 6DEE 6A08 EB9E D2BB AEAA 16F3
uid chenshake 
sub 2048R/02B4038D 2013-10-21

就是上面這個(gè)過程

在這個(gè)生成密鑰的過程中,有個(gè)步驟很重要,就是生成內(nèi)存隨機(jī)數(shù),命令如下:

dd if=/dev/zero of=test.dbf bs=9000 count=1000k .直到生成key為止。

#p#

查看私鑰

# gpg -k
/root/.gnupg/pubring.gpg
------------------------
pub 2048R/AEAA16F3 2013-10-21
uid chenshake
sub 2048R/02B4038D 2013-10-21

查看公鑰

# gpg --list-keys
/root/.gnupg/pubring.gpg
------------------------
pub 2048R/AEAA16F3 2013-10-21
uid chenshake 
sub 2048R/02B4038D 2013-10-21

導(dǎo)出公鑰

gpg -o chenshake.gpg -a --export chenshake

其中chenshake為用戶ID

chenshake.gpg為導(dǎo)出的公鑰文件

導(dǎo)出私鑰

gpg -o chenshake-private.gpg --export-secret-keys chenshake

導(dǎo)入秘鑰

公鑰和私鑰的導(dǎo)入,都是一樣。

gpg --import filename

公鑰

(另外一臺機(jī)器)

當(dāng)然你需要通過scp把公鑰復(fù)制到遠(yuǎn)程的機(jī)器

# gpg --import chenshake.gpg
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key AEAA16F3: public key "chenshake " imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

你也可以查看到導(dǎo)入的公鑰

# gpg --list-keys
/root/.gnupg/pubring.gpg
------------------------
pub 2048R/AEAA16F3 2013-10-21
uid chenshake 
sub 2048R/02B4038D 2013-10-21

公鑰加密

一個(gè)文件,我這里是加密cobbler.ks 這個(gè)文件,加密后是 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 
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 "
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 "

需要你輸入你當(dāng)初創(chuàng)建秘鑰的時(shí)候設(shè)置的那個(gè)密碼。這個(gè)時(shí)候,你就可以查看到加密的文件。

責(zé)任編輯:藍(lán)雨淚 來源: 博客園
相關(guān)推薦

2021-07-18 11:43:58

Linux密碼加密

2015-05-19 08:58:08

加密解密GnuPG

2021-05-08 05:56:15

加密OpenSSL密鑰

2024-03-01 09:58:44

2021-02-01 08:00:00

vimLinux加密

2022-09-26 08:35:53

磁盤Java解密

2023-12-13 12:27:46

2021-12-15 14:39:50

LinuxGPG加解密文件

2017-12-07 10:25:55

LinuxGPG加密解密

2023-09-01 09:31:48

2024-04-29 07:50:52

C#AES加密

2023-09-04 14:00:28

加密密鑰私鑰

2024-07-09 10:13:15

2023-03-06 08:49:02

加密和解密SpringBoot

2020-09-24 10:50:53

加密解密語言hmac

2015-03-26 11:25:10

對稱加密加密壓縮加密解密解壓

2024-08-26 08:34:47

AES加密算法

2011-08-01 14:14:36

加密技術(shù)

2024-09-09 08:53:56

2018-07-30 11:56:17

解密加密開發(fā)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 日本一级淫片免费啪啪3 | 中文字幕一区二区三区在线观看 | 午夜影院在线观看 | 欧美成人h版在线观看 | 久久久.com| 男人天堂网址 | 亚洲一区二区三 | 精品国产一区二区三区免费 | 成人久草| 男女视频在线免费观看 | 蜜桃一区二区三区在线 | 久久精品亚洲国产 | 在线视频中文字幕 | 日韩一区二区在线观看视频 | 欧美日韩在线播放 | 91精品国产91久久久久久吃药 | 成人高清视频在线观看 | 国产一区二区在线免费观看 | 久操亚洲 | 91麻豆精品国产91久久久久久久久 | 欧美日韩在线不卡 | 99久久免费精品视频 | 青青久在线视频 | 99re| 成人精品久久久 | 欧美大片一区 | 一区二区高清不卡 | 91精品一区 | 亚洲精品一区在线观看 | 亚洲精品乱码久久久久v最新版 | 精品美女在线观看 | 国产精品久久久久久一区二区三区 | 久久久.com | 成人福利视频网站 | av无遮挡 | 日韩精品999 | 三级在线视频 | 精品久久av | 特黄一级 | 久久精品国产免费 | 成人在线观看免费视频 |