If you’ve any personal or sensitive files stored on your Linux machine, you should consider encrypting them with GnuPG for added security.
Nowadays, news revolving around hacking, ransomware, and data compromise is very common. Therefore, it is important to be very vigilant in protecting personal files and sensitive data.
On Linux, you have GnuPG, a simple yet comprehensive encryption tool that you can use to secure important data on your system.
What Is GnuPG?
GnuPG or simply GPG is an encryption technique that has gained wide popularity because of its ease of use and top security algorithms. It is an open-source implementation of the Open PGP Standard.
Linux provides you with the GnuPG command-line utility to help users get familiar with GPG encryption and security keys. Apart from encrypting and securing files, GPG is also used in securing software and package downloads.
GitHub also gives you the option to use GPG as an alternative method to the traditional SSH keys.
Installing GnuPG on Linux
GPG is installed by default on most Debian-based distros such as Ubuntu and Lubuntu, but in case you do not have it installed, here’s how to install GnuPG on your system:
On Debian-based distros:
sudo apt install gnupg
On RHEL, Fedora, and similar distros:
sudo yum install gnupg
On Arch-based distros, switch to the root user using su and run the following command:
pacman -S gnupg
Encrypting a File Using GnuPG on Linux
You can use GPG to encrypt any file format. Let’s assume that you have an important file containing salaries for your organization; obviously, you do not want other people looking at this sensitive data.
The file data looks as follows:
To encrypt the file, simply run the command using the format gpg -c filename. For example, let’s encrypt salaries.txt, which is a text file located in the present working directory. Feel free to use any file to follow along.
gpg -c salaries.txt
The system will prompt you to provide a passphrase. Enter a secure passphrase and proceed.
GPG will create another file with the .gpg file extension appended to the original file name. If you run the ls command in your Documents directory or wherever your file is, you’ll notice that GPG has created an extra file.
Run the cat command to view the content of the newly encrypted GPG, and you’ll get some gibberish text, meaning your data is now encrypted.
To view the contents of the file, you’ll first need to decrypt it with GPG using the command:
gpg -d salaries.txt.gpg
You can now safely delete the unencrypted file using the rm command.
Secure Your Messages and Files Using GPG on Linux
GnuPG is a great tool for both encrypting and password-protecting your data on Linux. If you have sensitive data on your PC, you should consider encrypting it.
Apart from securing sensitive files with GPG, you can take your security awareness a step further and encrypt communication messages transmitted over the internet using GPG key pairs.
Read the full article here