GNU/Linux >> Belajar Linux >  >> Cent OS

Cara menghasilkan kunci PGP menggunakan GPG di Linux

Cara membuat kunci PGP menggunakan GPG di Linux

Aplikasi Penjaga Privasi GNU memungkinkan Anda untuk mengenkripsi dan mendekripsi informasi, membuat kunci enkripsi publik dan pribadi, dan menggunakan atau memverifikasi tanda tangan digital. GPG didasarkan pada penggunaan sepasang kunci, satu publik dan satu pribadi (atau "rahasia"). Data yang dienkripsi dengan satu kunci hanya dapat didekripsi dengan kunci lainnya. Untuk mengenkripsi pesan kepada Anda, seseorang akan menggunakan kunci publik Anda untuk membuat pesan yang hanya dapat dibuka dengan kunci pribadi Anda. Untuk menandatangani informasi, Anda akan menguncinya dengan kunci pribadi Anda, memungkinkan siapa pun untuk memverifikasi bahwa itu berasal dari Anda dengan membukanya dengan kunci publik Anda.

GPG memiliki lusinan opsi tambahan yang menyempurnakan opsi yang tersedia. Dalam posting ini kita akan melihat cara menghasilkan kunci PGP menggunakan GPG di Linux.

Langkah 1 :Konfirmasi versi GPG.

# gpg --help

gpg (GnuPG) 1.4.5
Copyright (C) 2006 Free Software Foundation, Inc.

Langkah 2 :Memulai proses pembuatan kunci. Masukkan perintah berikut untuk mulai membuat kunci Anda:

gpg --gen-key

Select the type of key

Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)      ## SELECT THIS OPTION
Your selection? 5

Select the key size

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048

Requested keysize is 2048 bits

Select the expiration time

Please specify how long the key should be valid.
0 = key does not expire                 ## SELECT THIS OPTION
 = 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) 0

Key does not expire at all

Is this correct? (y/N) y

Enter user name and email

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: 

"[NAME]" (xyz-comment) [USERNAME]@[DOMAIN_NAME].com"

Real name: [Name]
Email address: [USERNAME]@[DOMAIN_NAME].com
Comment: comment
You selected this USER-ID:
"[Name] (comment) [USERNAME]@[DOMAIN_NAME].com"

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

Enter passphrase to protect secret key

You need a Passphrase to protect your secret key.

Enter passphrase: *******
Repeat passphrase: *******

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.

You may see the following message. If you do, follow the instructions and the key generation process will start automatically.

Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 284 more bytes)

..+++++
...+++++
gpg: key F709C771 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, 0m, 0n, 0f, 1u
pub: 2048R/F709C771 2015-05-27
key fingerprint = BDC2 5293 DB14 C218 D2DA 711C EB0A 564A F709 C771
uid [Name] (comment) [USERNAME]@[DOMAIN_NAME].com

Perhatikan bahwa kunci ini tidak dapat digunakan untuk enkripsi. Anda mungkin ingin menggunakan perintah “–edit-key ” untuk menghasilkan subkunci untuk tujuan ini. Pembuatan kunci selesai. Pada titik ini, Anda telah membuat pasangan kunci privat/publik dengan kunci publik yang dapat digunakan untuk tujuan penandatanganan. Langkah selanjutnya adalah menambahkan subkey yang akan digunakan untuk enkripsi.

Langkah 3 :Menambahkan subkunci untuk enkripsi. Masukkan perintah berikut untuk mulai membuat kunci Anda:

# gpg --edit-key '[NAME]'
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.

Secret key is available.

pub 2048R/F709C771 created: 2015-05-27 expires: never usage: SC
trust: ultimate validity: ultimate
[ultimate] (1). [Name] (comment) [USERNAME]@[DOMAIN_NAME].com

Enter the edit-key command

Command> addkey

Key is protected.

Enter the passphrase you specified in step 2

You need a passphrase to unlock the secret key for
user: "[NAME] (comment) [USERNAME]@[DOMAIN_NAME].com"
2048-bit RSA key, ID F709C771, created 2015-05-27

Enter passphrase: *******

user: "[Name] (comment) [USERNAME]@[DOMAIN_NAME].com"
2048-bit RSA key, ID F709C771, created 2015-05-27

Select the type of key

Please select what kind of key you want:
(2) DSA (sign only)
(4) Elgamal (encrypt only)
(5) RSA (sign only)
(6) RSA (encrypt only)              ## SELECT THIS OPTION
Your selection? 6

Select the key size

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048

Requested keysize is 2048 bits

Select the expiration time

Please specify how long the key should be valid.
0 = key does not expire       ## SELECT THIS OPTION
 = 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) 0

Key does not expire at all
Is this correct? (y/N) Y
Really create? (y/N) Y

Kita perlu menghasilkan banyak byte acak. Ini adalah ide yang baik untuk melakukan beberapa tindakan lain (ketik pada keyboard, gerakkan mouse, gunakan disk) selama generasi utama; ini memberikan peluang yang lebih baik kepada pembuat angka acak untuk mendapatkan entropi yang cukup.

Anda mungkin melihat pesan berikut. Jika Anda melakukannya, ikuti instruksi dan proses pembuatan subkunci akan dimulai secara otomatis.

Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 277 more bytes)

..........+++++
..........+++++

pub 2048R/F709C771 created: 2015-05-27 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/13DA9D02 created: 2015-05-27 expires: never usage: E
[ultimate] (1). [Name] (comment) [USERNAME]@[DOMAIN_NAME].com

Note, pub is for signing (SC), sub is for encryption (E)

Exit the edit-key editor and save your changes

Command> q
Save changes? (y/N) y

Pembuatan subkunci untuk tujuan enkripsi selesai. Langkah selanjutnya adalah memverifikasi dan mengekspor kunci.

Langkah 4 :Daftar kunci Anda. Masukkan perintah berikut untuk membuat daftar kunci pada gantungan kunci Anda:

# gpg -k
/home/[USERNAME]/.gnupg/pubring.gpg
--------------------------------
pub 2048R/F709C771 2015-05-27
uid Your [NAME] (comment) [USERNAME]@[DOMAIN_NAME].com
sub 2048R/13DA9D02 2015-05-27

Langkah 5 – Ekspor kunci publik (termasuk subkunci) dalam format ASCII. Masukkan perintah berikut untuk membuat daftar kunci:

# gpg --armor --output [Name]-pub-sub.asc --export '[Name]'
# cat [NAME]-pub-sub.asc

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)

“[.......Removed the PGP KEY...... ]”

-----END PGP PUBLIC KEY BLOCK-----


Cent OS
  1. Cara mengkonfigurasi kunci SSH menggunakan cPanel

  2. Bagaimana Cara Membuat Kunci SSH di Server Khusus Linux ?

  3. Cara Membuat (dan Menerbitkan) Kunci PGP di Linux Menggunakan GUI

  1. Cara Membuat Permintaan Penandatanganan Sertifikat (CSR) di Linux

  2. Bagaimana Mengonversi File PPK ke OpenSSH Keys dan Login menggunakan SSH di Linux?

  3. Cara Mengenkripsi dan Mendekripsi File menggunakan GnuPG di Linux

  1. Cara Membuat &Mengatur Kunci SSH di CentOS 7

  2. Cara Membuat &Mengatur Kunci SSH di Debian 10

  3. Cara Mengatur Kunci SSH di CentOS 8