5 Tools to Encrypt Decrypt and Password Protect Files in Linux


In today's world, data privacy is more important than ever. With a multitude of online threats, it's crucial to keep your personal and professional data safe and secure. One of best ways to do this is by using encryption and password protection. If you're a Linux user, you're in luck because Linux offers several powerful tools to encrypt, decrypt, and password protect your files. In this article, we'll discuss 5 of best tools available in Linux and how to use them.

GPG

GPG, or GNU Privacy Guard, is a free and open-source encryption tool that uses OpenPGP standard. It's a widely used tool that offers both symmetric and asymmetric encryption. With GPG, you can encrypt files with a password or a public key. You can also sign your files to ensure their authenticity.

To use GPG, you first need to install it on your Linux machine. To do this, open a terminal window and type following command −

sudo apt-get install gnupg

Once GPG is installed, you can use following command to encrypt a file −

gpg -c filename

This will encrypt file with a password. You'll be prompted to enter password twice. To decrypt file, use following command −

gpg filename.gpg

You'll be prompted to enter password to decrypt file.

OpenSSL

OpenSSL is another popular open-source encryption tool that's widely used on Linux machines. It offers a wide range of encryption and decryption options, including AES, DES, and Blowfish. You can use OpenSSL to encrypt files with a password or a public key.

To use OpenSSL, you first need to install it on your Linux machine. To do this, open a terminal window and type following command −

sudo apt-get install openssl

Once OpenSSL is installed, you can use following command to encrypt a file −

openssl enc -aes-256-cbc -salt -in filename -out filename.enc

This will encrypt file with a password. You'll be prompted to enter password twice. To decrypt file, use following command −

openssl enc -aes-256-cbc -d -in filename.enc -out filename

You'll be prompted to enter password to decrypt file.

Ccrypt

ccrypt is a simple and easy-to-use encryption tool that's designed for Linux machines. It uses Rijndael algorithm for encryption and decryption. ccrypt offers both symmetric and asymmetric encryption.

To use ccrypt, you first need to install it on your Linux machine. To do this, open a terminal window and type following command −

sudo apt-get install ccrypt

Once ccrypt is installed, you can use following command to encrypt a file −

ccrypt filename

This will encrypt file with a password. You'll be prompted to enter password twice. To decrypt file, use following command −

ccrypt -d filename.cpt

You'll be prompted to enter password to decrypt file.

Cryptsetup

Cryptsetup is a Linux tool that's used for disk encryption. It's a powerful tool that can be used to encrypt entire partitions or hard drives. With Cryptsetup, you can use both symmetric and asymmetric encryption.

To use Cryptsetup, you first need to install it on your Linux machine. To do this, open a terminal window and type following command −

sudo apt-get install cryptsetup

Once Cryptsetup is installed, you can use following command to create an encrypted partition −

sudo cryptsetup luks

This command will create an encrypted partition on specified device. You'll be prompted to enter a passphrase to encrypt partition. Once partition is created, you can use following command to open it −

sudo cryptsetup luksOpen /dev/sdb1 myencrypteddrive

This command will open encrypted partition and create a mapping to it with name "myencrypteddrive". To access files on partition, you'll need to mount it. You can do this using following command −

sudo mount /dev/mapper/myencrypteddrive /mnt/myencrypteddrive

This command will mount partition to specified directory.

VeraCrypt

VeraCrypt is a free and open-source encryption tool that's designed for Linux, Windows, and macOS machines. It's a powerful tool that can be used to encrypt entire partitions or hard drives. VeraCrypt uses several encryption algorithms, including AES, Serpent, and Twofish.

To use VeraCrypt, you first need to install it on your Linux machine. You can download it from official website. Once VeraCrypt is installed, you can use following command to create an encrypted volume −

veracrypt -c /path/to/volume

This command will create a new encrypted volume at specified location. You'll be prompted to enter a passphrase to encrypt volume. Once volume is created, you can use following command to mount it −

veracrypt /path/to/volume /path/to/mount/point

This command will mount encrypted volume to specified directory.

EncFS

EncFS is a free and open-source encryption tool that's designed to encrypt individual files and folders. It's easy to use and offers both symmetric and asymmetric encryption. EncFS uses FUSE (Filesystem in Userspace) interface to provide a virtual encrypted filesystem.

To use EncFS, you first need to install it on your Linux machine. To do this, open a terminal window and type following command −

sudo apt-get install encfs

Once EncFS is installed, you can use following command to create an encrypted folder −

encfs ~/encrypted ~/decrypted

This command will create an encrypted folder at specified location and mount it to specified directory. You'll be prompted to enter a password to encrypt folder. To access files in folder, simply navigate to mount point and enter password.

Aescrypt

Aescrypt is a free and open-source encryption tool that's designed to encrypt individual files. It uses AES encryption algorithm and offers both symmetric and asymmetric encryption. Aescrypt is easy to use and can be used from command line or with a graphical interface.

To use Aescrypt, you first need to install it on your Linux machine. To do this, open a terminal window and type following command −

sudo apt-get install aescrypt

Once Aescrypt is installed, you can use following command to encrypt a file −

aescrypt -e filename

This command will encrypt file with a password. You'll be prompted to enter password twice. To decrypt file, use following command −

aescrypt -d filename.aes

You'll be prompted to enter password to decrypt file.

Gnome Encfs Manager

Gnome Encfs Manager is a graphical user interface for EncFS. It's easy to use and allows you to create and manage encrypted folders with a few clicks. Gnome Encfs Manager is available for Ubuntu and other Debian-based distributions.

To install Gnome Encfs Manager, open a terminal window and type following command −

sudo apt-get install gnome-encfs-manager

Once Gnome Encfs Manager is installed, you can launch it from applications menu. To create a new encrypted folder, click on "New" button and follow prompts. To access files in folder, simply click on folder in Gnome Encfs Manager interface and enter password.

LUKS

Linux Unified Key Setup (LUKS) is a disk encryption specification that's used to encrypt entire partitions or hard drives. It's a powerful tool that can be used to secure your entire system. LUKS is built into many Linux distributions and is easy to use.

To use LUKS, you first need to create a new partition that you want to encrypt. You can use "fdisk" command to create a new partition. Once you've created partition, use following command to encrypt it −

sudo cryptsetup luksFormat /dev/sdb1

This command will encrypt partition and prompt you to enter a passphrase. Once partition is encrypted, use following command to open it −

sudo cryptsetup luksOpen /dev/sdb1 myencrypteddrive

This command will open encrypted partition and create a mapping to it with name "myencrypteddrive".

dm-crypt

dm-crypt is a disk encryption tool that's built into Linux kernel. It's a powerful tool that can be used to encrypt entire partitions or hard drives. dm-crypt uses AES encryption algorithm and offers both symmetric and asymmetric encryption.

To use dm-crypt, you first need to create a new partition that you want to encrypt. You can use "fdisk" command to create a new partition. Once you've created partition, use following command to encrypt it −

sudo cryptsetup --verify-passphrase luksFormat /dev/sdb1

This command will encrypt partition and prompt you to enter a passphrase. Once partition is encrypted, use following command to open it −

sudo cryptsetup luksOpen /dev/sdb1 myencrypteddrive

This command will open encrypted partition and create a mapping to it with name "myencrypteddrive".

Conclusion

In conclusion, Linux offers several powerful tools for encrypting, decrypting, and password protecting your files. Whether you're looking to encrypt a single file or an entire hard drive, these tools have you covered. GPG, OpenSSL, ccrypt, Cryptsetup, and VeraCrypt are all excellent options that offer different levels of security and functionality. By using these tools, you can ensure that your personal and professional data stays safe and secure.

Updated on: 11-Apr-2023

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements