How to Encrypt and Decrypt a file in Linux using (GnuPG) ?

There could be many ways to Encrypt and Decrypt a file in Linux. some times it is mandatory to Encrypt the data or information sending across network, there could be change of getting hacked and misused the information.

The one which I use to Encrypt and Decrypt is, gpg (GnuPG).
Below shown the steps to encrypt and decrypt a file.

First create a file to encrypt

# echo 'TecGeeks.com' > DD-1.txt
# cat DD-1.txt
TecGeeks.com

Run the command gpg -c filename to encrypt the file, this will ask you to put the passwrd to encrypt
# gpg -c DD-1.txt
Enter passphrase: <secret word>
Repeat passphrase: <secret word>



List the files, you will see two files one  is encrypted with .gpg extension and one is pain txt 

#ls -l DD-1*
-rw-rw-r-- 1 jack jack 13 Jan 13 10:37 DD-1.txt
-rw-rw-r-- 1 jack jack 91 Jan 13 10:38 DD-1.txt.gpg

Now to try to open encrypted files, you will see data is encrypted
 #cat DD-1.txt.gpg
ê2Ãà pisÃu?î^ó5Ã\<dÃ

Run The command gpg -g file name to decrypt the file.

#gpg -d DD-1.txt.gpg
gpg: keyring `/home/jack/.gnupg/secring.gpg' created
gpg: AES encrypted data
gpg: gpg-agent is not available in this session
gpg: encrypted with 1 passphrase
TecGeeks.com

The config file for 'gpg' is /home/username/.gnupg/gpg.conf
How to Encrypt and Decrypt a file in Linux using (GnuPG) ? How to Encrypt and Decrypt a file in Linux using (GnuPG) ? Reviewed by TecGeeks News on January 12, 2017 Rating: 5

No comments:

Get Your Business Online Now


Powered by Blogger.