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
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>
#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
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
The config file for ‘gpg’ is /home/username/.gnupg/gpg.conf
Your Profile can also be listed here, Want to share you Experience, become a TecGeeks Author Submit here
Latest posts by Rahul Kansi (see all)
- Former US president admits he ordered cyber attacks on North Korea - March 6, 2017
- Deny SSH Access to Particular User and Group - February 25, 2017
- How to Change Host-Name in Linux Without Rebooting - February 25, 2017