(1) First add 2 users
[root@CLIENT ~]# useradd alice
[root@CLIENT ~]# useradd bob
[root@CLIENT ~]# passwd alice
[root@CLIENT ~]# passwd bob
(2) Login user alice
[root@CLIENT ~]# su - alice
[alice@CLIENT ~]$
(3) After that generate pub/private key using gpg
[alice@CLIENT ~]$ gpg --gen-key
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.
gpg: directory `/home/alice/.gnupg' created
gpg: new configuration file `/home/alice/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/alice/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/alice/.gnupg/secring.gpg' created
gpg: keyring `/home/alice/.gnupg/pubring.gpg' created
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E 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
<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)
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) <heinrichh@duesseldorf.de>"
Real name: alice
Email address: it1708151@gmail.com
Comment: hello
You selected this USER-ID:
"alice (hello) <it1708151@gmail.com>"
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.
.++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++++++++++++.+++++++++++++++++++++++++++++++++++..++++++++++.+++++++++++++++>+++++..+++++.................................................+++++
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 280 more bytes)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>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: /home/alice/.gnupg/trustdb.gpg: trustdb created
gpg: key 7F6BF7DD 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 1024D/7F6BF7DD 2013-12-27
Key fingerprint = 24A0 9F3D 007E 29F8 5FC1 E2AC B3E0 74B9 7F6B F7DD
uid alice (hello) <it1708151@gmail.com>
sub 2048g/EDC1CF28 2013-12-27
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.
gpg: directory `/home/alice/.gnupg' created
gpg: new configuration file `/home/alice/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/alice/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/alice/.gnupg/secring.gpg' created
gpg: keyring `/home/alice/.gnupg/pubring.gpg' created
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E 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
<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)
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) <heinrichh@duesseldorf.de>"
Real name: alice
Email address: it1708151@gmail.com
Comment: hello
You selected this USER-ID:
"alice (hello) <it1708151@gmail.com>"
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.
.++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++++++++++++.+++++++++++++++++++++++++++++++++++..++++++++++.+++++++++++++++>+++++..+++++.................................................+++++
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 280 more bytes)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>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: /home/alice/.gnupg/trustdb.gpg: trustdb created
gpg: key 7F6BF7DD 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 1024D/7F6BF7DD 2013-12-27
Key fingerprint = 24A0 9F3D 007E 29F8 5FC1 E2AC B3E0 74B9 7F6B F7DD
uid alice (hello) <it1708151@gmail.com>
sub 2048g/EDC1CF28 2013-12-27
(4) To check key either generated or not we can see both public and private key
[alice@CLIENT ~]$
gpg --list-key
/home/alice/.gnupg/pubring.gpg
------------------------------
pub 1024D/7F6BF7DD 2013-12-27
uid alice (hello) <it1708151@gmail.com>
sub 2048g/EDC1CF28 2013-12-27
[alice@CLIENT ~]$ gpg --secret-key
gpg: Missing argument for option "--secret-key"
[alice@CLIENT ~]$ gpg --list-secret-key
/home/alice/.gnupg/secring.gpg
------------------------------
sec 1024D/7F6BF7DD 2013-12-27
uid alice (hello) <it1708151@gmail.com>
/home/alice/.gnupg/pubring.gpg
------------------------------
pub 1024D/7F6BF7DD 2013-12-27
uid alice (hello) <it1708151@gmail.com>
sub 2048g/EDC1CF28 2013-12-27
[alice@CLIENT ~]$ gpg --secret-key
gpg: Missing argument for option "--secret-key"
[alice@CLIENT ~]$ gpg --list-secret-key
/home/alice/.gnupg/secring.gpg
------------------------------
sec 1024D/7F6BF7DD 2013-12-27
uid alice (hello) <it1708151@gmail.com>
ssb 2048g/EDC1CF28 2013-12-27
(5) Export the public key
[alice@CLIENT ~]$
gpg --export --armor alice > /tmp/alice.key
_________________________________________________________________
7) Login user bob
[root@CLIENT ~]# su - bob
[bob@CLIENT ~]$
(8) User bob need public key of alice so bob import the alice pub key
[bob@CLIENT ~]$ gpg --import /tmp/alice.key
gpg: directory `/home/bob/.gnupg' created
gpg: new configuration file `/home/bob/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/bob/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/bob/.gnupg/secring.gpg' created
gpg: keyring `/home/bob/.gnupg/pubring.gpg' created
gpg: /home/bob/.gnupg/trustdb.gpg: trustdb created
gpg: key 7F6BF7DD: public key "alice (hello) <it1708151@gmail.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: new configuration file `/home/bob/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/bob/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/bob/.gnupg/secring.gpg' created
gpg: keyring `/home/bob/.gnupg/pubring.gpg' created
gpg: /home/bob/.gnupg/trustdb.gpg: trustdb created
gpg: key 7F6BF7DD: public key "alice (hello) <it1708151@gmail.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
(8) Create a file
[bob@CLIENT ~]$ vim msg
(8) Encrypt the msg file
[bob@CLIENT ~]$ gpg --encrypt --armor --recipient alice msg
gpg: EDC1CF28: There is no assurance this key belongs to the named user
pub 2048g/EDC1CF28 2013-12-27 alice (hello) <it1708151@gmail.com>
Primary key fingerprint: 24A0 9F3D 007E 29F8 5FC1 E2AC B3E0 74B9 7F6B F7DD
Subkey fingerprint: CFAC B364 6421 F375 28FC 0C5C 8516 C564 EDC1 CF28
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
gpg: EDC1CF28: There is no assurance this key belongs to the named user
pub 2048g/EDC1CF28 2013-12-27 alice (hello) <it1708151@gmail.com>
Primary key fingerprint: 24A0 9F3D 007E 29F8 5FC1 E2AC B3E0 74B9 7F6B F7DD
Subkey fingerprint: CFAC B364 6421 F375 28FC 0C5C 8516 C564 EDC1 CF28
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
(9) Mail it to user alice
[bob@CLIENT ~]$ mail alice < msg.asc
_________________________________________________________________________________
(10) login user alice to check the mail
[alice@CLIENT ~]$
mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/alice": 1 message 1 unread
>U 1 bob@CLIENT Sat Dec 28 05:07 33/1415
& w
No file specified.
& w hello #---- w stands for download
"hello" [New file]
& q
[alice@CLIENT ~]$ hello
-bash: hello: command not found
[alice@CLIENT ~]$ vim hello
[alice@CLIENT ~]$ gpg hello
You need a passphrase to unlock the secret key for
user: "alice (hello) <it1708151@gmail.com>"
2048-bit ELG-E key, ID EDC1CF28, created 2013-12-27 (main key ID 7F6BF7DD)
gpg: encrypted with 2048-bit ELG-E key, ID EDC1CF28, created 2013-12-27
"alice (hello) <it1708151@gmail.com>"
gpg: hello: unknown suffix
Enter new filename [msg]: hello
File `hello' exists. Overwrite? (y/N) y
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/alice": 1 message 1 unread
>U 1 bob@CLIENT Sat Dec 28 05:07 33/1415
& w
No file specified.
& w hello #---- w stands for download
"hello" [New file]
& q
[alice@CLIENT ~]$ hello
-bash: hello: command not found
[alice@CLIENT ~]$ vim hello
[alice@CLIENT ~]$ gpg hello
You need a passphrase to unlock the secret key for
user: "alice (hello) <it1708151@gmail.com>"
2048-bit ELG-E key, ID EDC1CF28, created 2013-12-27 (main key ID 7F6BF7DD)
gpg: encrypted with 2048-bit ELG-E key, ID EDC1CF28, created 2013-12-27
"alice (hello) <it1708151@gmail.com>"
gpg: hello: unknown suffix
Enter new filename [msg]: hello
File `hello' exists. Overwrite? (y/N) y
_________________________________________________________________
No comments:
Post a Comment