How to Encrypt Sensitive Files Using GnuPG on Linux

If you have personal or confidential files stored on your Linux machine, consider encrypting them with GnuPG for added security.

Today, news related to hacking, ransomware, and data breaches are widespread. Therefore, it is important to be very vigilant in protecting personal files and sensitive data.

On Linux, you have GnuPG, a simple but powerful 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 due to its ease of use and top-notch 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 learn about GPG encryption and security keys. Besides encrypting and securing files, GPG is also used to secure software and package downloads.

GitHub also gives you the option to use GPG as an alternative method to the traditional SSH keys.

Install GnuPG on Linux

GPG is installed by default on most Debian-based distributions such as Ubuntu and Lubuntu, but in case you don’t have it installed, you can install GnuPG on your system as follows:

On Debian-based distributions:

sudo apt install gnupg

On RHEL, Fedora and similar distributions:

sudo yum install gnupg

For Arch-based distributions, switch to the root user with so and run the following command:

pacman -S gnupg

Encrypting a file with GnuPG on Linux

You can use GPG to encrypt any file format. Let’s say you have an important salary file for your organization; Obviously you don’t want other people to see this sensitive data.

The file data looks like this:

To encrypt the file, just run the command with the format gpg -c filename. For example, let’s encrypt Salaries.txt, which is a text file located in the current working directory. Feel free to use any file to join.

gpg -c salaries.txt

The system will ask you to enter a passphrase. Enter a secure passphrase and continue.

GPG creates 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 located, you will find that GPG has created an additional file.

Run the cat command to view the contents of the newly encrypted GPG, and you’ll get gibberish text, meaning your data is now encrypted.

cat salaries.txt.gpg

To view the contents of the file, you must first decrypt it using GPG with the following command:

gpg -d salaries.txt.gpg

You can now safely delete the unencrypted file using the rm command.

Backup your messages and files with GPG on Linux

GnuPG is a great tool to both encrypt and password protect your data on Linux. If you have sensitive data on your PC, you should encrypt it.

Aside from securing sensitive files with GPG, you can take your security awareness one step further and encrypt communication messages transmitted over the Internet with GPG key pairs.

Read  How to form strong relationships for academic success. – Brock Press

Leave a Comment

Your email address will not be published.