PGP and GPG Secure Data Communication on two Linux machine

If you really loves Linux or more familiar with it and want to communicate securely between two Linux machine then follow the simple steps as bellow. In windows you can also communicate securely.

Secure Data Communication on two Linux machine with PGP/GPG.

1. First Generate public/private key pair using sshd-generate on both Linux  machine.

To work securely with Linux,first of all we need to generate public/private key pair as mentioned bellow. It will generate keypair and also shows random-art image of the key.

1_on both machine

2. Start ssh service on both Linux machines.

Now next step is to perform initialization of secure shell (ssh) i.e. to start ssh on both machine.

2_on both machines

3. Use GNUPG (GNU Privacy Guard) one machine.

GnuPG allows to encrypt and sign your data and communication.GnuPG is also known as GPG.

Select kind of key you want.
Select Size Of Key.
Select Validation Period for Key.
Add Identity of user to identify your key like name,comment,email etc.
Press O if you are done with that and finally you need pass-phrase to protect your secret key.
As the system require lot of random bytes so ,do some other interactive task like open other application or type on keyboard until OS collects the more entropy.

3_oneside

4_oneside

5_oneside

4. Export Public key pub.asc as bellow.

now its time to export the public key as pub.asc.

6_one side

5. Export Private key pri.asc as bellow.

As we have performed export for public key as pub.asc above, we need to perform export step for private key as pri.asc also.

7_oneside

6. Copy public key from one machine to other machine using scp as bellow.

now by using scp(secured copy) function we need to copy public key from one Linux machine to another one.

8_copy from oneside to other

7. Import pub.asc(public key) on other side.

As we have copied public key in previous step,now import that public key.

9_on other side

 

8. encryption at other side.

make a file test.txt and write something inside that.Now encrypt that file content as mentioned.

10_encrypt otherside

9.Encrypted file as .gpg extension.

Now you can see the encrypted content as bellow as test.txt.gpg.

11_encrypted file

10.Transfer the encrypted file.

transfer encrypted file to other side or on another linux machine using scp.

12_transfer file to oneside

11.import pub.asc on other Linux machine.
You cans see the content of the transferred file as in encrypted form.now its time to import the public key on local machine for further communication.

13_import on one side

12. decrypt on one side.

Now we are going to decrypt the test.txt.gpg file on another side using gpg -d test.txt.gpg and now you can see the original document content.
14_decrypt on one side
This is how encryption and decryption performed between two Linux machine using PGP/GPG.

You can also perform ssh and scp from local to remote machine without password.
Thanks for reading this article.
If  you really like this page than hit like or share it on any social network to spread among all.
Hope you enjoyed. Thanks for reading this article and Feels free to ask or comment below.

Leave a Comment