Encryption is something as Linux users we should all take a little more seriously. Especially in the age of cyber warfare, corporate espionage, and state-sanctioned privacy invasions taking place. Trouble is, many users have no idea where to start when it comes to locking up personal data. In this tutorial, we’ll go over three ways you can easily encrypt files on Linux for safekeeping.
GnuPG is by far the easiest way to encrypt files on Linux. It is the foundation for (almost) all encryption on Linux. Chances are that GnuPG is already installed on your Linux PC. Just in case your Linux distribution doesn’t already have GnuPG, you can install it by opening a terminal, and searching for “gpg”. GnuPG is widely used, so every major Linux distribution carries it.
To encrypt files with GnuPG, first open a terminal window. Inside the terminal, think about what you’d like to lock away, and move the terminal to that area of your filesystem. For example: to encrypt files in Documents, you’d use the cd command to go to that directory.
Once in the folder you’d like to encrypt in, use the ls command to view all files inside of the directory.
Pick out what you want to encrypt using GnuPG. Then, run the encryption process with:
gpg -c file
Decrypt the encrypted file by using the decrypt command.
2. Encrypting using the Archive Manager
Many of the archiving tools on Linux support a basic level of encryption. This kind of thing is perfect if you’re not holding on to company secrets, or something like that. Locking away personal files can be as easy as creating a ZIP/TAR/7Z/Etc archive file. To get started, open your Linux file manager, and navigate to the particular files you’re trying to encrypt.
In the file manager, highlight the file (or folder), and right-click it. In the right-click menu, select “create archive”. Select the option to “compress to” (or equivalent). Selecting this option will open up the archive manager tool, instead of just creating an archive on the spot.
Note: Instead of ‘Create archive’ the right-click menu might have an option that says “compress”, or something similar.
Many different archive formats support encryption. That said, select “ZIP”, as it’s the most universal format and has good encryption support. After selecting “ZIP”, look for “password protection“, or something similar.
This will reveal an encryption menu. Inside the encryption menu, look for and select the level of encryption you’d like to use. Enter a password, and click the OK button to start the compression process.
To decrypt, right-click on the archive inside the file manager, and select “decompress”. The user will then be asked to enter the password to continue.
Another quick and easy way to encrypt files on Linux is with the mCrypt tool. Like GnuPG, it’s terminal based, and available on most major Linux distributions. Using a quick command or two, users can easily lock away sensitive files.
To get going with mCrypt, select your operating system from the list, and install it.
sudo apt install mcrypt
sudo apt-get install mcrypt
Arch Linux doesn’t carry Mcrypt in the normal package repositories. Instead, to use it, you’ll need to download it from the AUR using an AUR helper. Point your AUR helper at this package, or go download the snapshot to install it manually.
sudo dnf install mcrypt
sudo zypper install mcrypt
First, use the terminal to go to a directory where you’d like to lock up your files. In this example, the files will be in /home/username/Downloads/.
Inside the download directory, use the ls command to reveal all files.
Look through the file listing that the ls command shows, and find the names of the files you’re looking to encrypt. Then, use mcrypt to lock them up with:
It’s also possible to encrypt multiple files,with no limits.
mcrypt secretfile1 secretfile2
After running this operation, the Mcrypt tool will ask the user to enter a password. Be sure to use a secure, memorable password to encrypt your files.
Unlocking an encrypted mCrypt archive is fairly straightforward. To start off, be sure to CD into the directory where the encrypted archive is. According to the example, files were encrypted in ~/Downloads, so use the cd command to navigate to that location.
Then, start the decryption process:
mcrypt -d secretfile1.nc secretfile2.nc
Encrypting personal files on Linux isn’t as difficult as it sounds. In fact, with just a few little commands, you can easily take sensitive personal documents, pictures, etc, lock them up and keep them safe.
It’d be nice if Linux distribution developers standardized encrypting files, and provided one solution. Till then, it looks as if we’ll need to settle for tools like GPG, mCrypt and others.