- 7 Tools to Encrypt/Decrypt and Password Protect Files in Linux
- 1. GnuPG
- 2. bcrypt
- 3. ccrypt
- 4. Zip
- 5. Openssl
- 6. 7-zip
- 7. Nautilus Encryption Utility
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How to Encrypt Files in Linux
- Keep your information safe from prying eyes
- Hide Files With File Manager
- Use Encryption Software
- Encrypt Files with a GUI
- How to Decrypt Individual Files
- How to Encrypt a Folder
7 Tools to Encrypt/Decrypt and Password Protect Files in Linux
Encryption is the process of encoding files in such a way that only those who are authorized can access it. Mankind is using encryption from ages even when computers were not in existence. During war they would pass some kind of message that only their tribe or those who are concerned were able to understand.
Linux distribution provides a few standard encryption/decryption tools that can prove to be handy at times. Here in this article we have covered 7 such tools with proper standard examples, which will help you to encrypt, decrypt and password protect your files.
If you are interested in knowing how to generate Random password in Linux as well as creating random password you may like to visit the below link:
1. GnuPG
GnuPG stands for GNU Privacy Guard and is often called as GPG which is a collection of cryptographic software. Written by GNU Project in C programming Language. Latest stable release is 2.0.27.
In most of the today’s Linux distributions, the gnupg package comes by default, if in-case it’s not installed you may apt or yum it from repository.
We have a text file (tecmint.txt) located at
/Desktop/Tecmint/, which will be used in the examples that follows this article.
Before moving further, check the content of the text file.
Now encrypt tecmint.txt file using gpg. As soon as you run the gpc command with option -c (encryption only with symmetric cipher) it will create a file texmint.txt.gpg. You may list the content of the directory to verify.
Note: Enter Paraphrase twice to encrypt the given file. The above encryption was done with CAST5 encryption algorithm automatically. You may specify a different algorithm optionally.
To see all the encryption algorithm present you may fire.
Now, if you want to decrypt the above encrypted file, you may use the following command, but before we start decrypting we will first remove the original file i.e., tecmint.txt and leave the encrypted file tecmint.txt.gpg untouched.
Note: You need to provide the same password you gave at encryption to decrypt when prompted.
2. bcrypt
bcrypt is a key derivation function which is based upon Blowfish cipher. Blowfish cipher is not recommended since the time it was figured that the cipher algorithm can be attacked.
If you have not installed bcrypt, you may apt or yum the required package.
Encrypt the file using bcrypt.
As soon as you fire the above command, a new file name texmint.txt.bfe is created and original file tecmint.txt gets replaced.
Decrypt the file using bcrypt.
Note: bcrypt do not has a secure form of encryption and hence it’s support has been disabled at least on Debian Jessie.
3. ccrypt
Designed as a replacement of UNIX crypt, ccrypt is an utility for files and streams encryption and decryption. It uses Rijndael cypher.
If you have not installed ccrypt you may apt or yum it.
Encrypt a file using ccrypt. It uses ccencrypt to encrypt and ccdecrypt to decrypt. It is important to notice that at encryption, the original file (tecmint.txt) is replaced by (tecmint.txt.cpt) and at decryption the encrypted file (tecmint.txt.cpt) is replaced by original file (tecmint.txt). You may like to use ls command to check this.
Provide the same password you gave during encryption to decrypt.
4. Zip
It is one of the most famous archive format and it is so much famous that we generally call archive files as zip files in day-to-day communication. It uses pkzip stream cipher algorithm.
If you have not installed zip you may like to apt or yum it.
Create a encrypted zip file (several files grouped together) using zip.
Here mypassword is the password used to encrypt it. A archive is created with the name tecmint.zip with zipped files tecmint.txt, tecmint1.txt and tecmint2.txt.
Decrypt the password protected zipped file using unzip.
You need to provide the same password you provided at encryption.
5. Openssl
Openssl is a command line cryptographic toolkit which can be used to encrypt message as well as files.
You may like to install openssl, if it is not already installed.
Encrypt a file using openssl encryption.
Explanation of each option used in the above command.
- enc : encryption
- -aes-256-cbc : the algorithm to be used.
- -in : full path of file to be encrypted.
- -out : full path where it will be decrypted.
Decrypt a file using openssl.
6. 7-zip
The very famous open source 7-zip archiver written in C++ and able to compress and uncompress most of the known archive file format.
If you have not installed 7-zip you may like to apt or yum it.
Compress files into zip using 7-zip and encrypt it.
Decompress encrypted zip file using 7-zip.
Note: Provide same password throughout in encryption and decryption process when prompted.
All the tools we have used till now are command based. There is a GUI based encryption tool provided by nautilus, which will help you to encrypt/decrypt files using Graphical interface.
7. Nautilus Encryption Utility
Steps to encrypt files in GUI using Nautilus encryption utility.
Encryption of file in GUI
1. Right click the file you want to encrypt.
2. Select format to zip and provide location to save. Provide password to encrypt as well.
Encrypt File Using Nautilus
3. Notice the message – encrypted zip created successfully.
Encrypted Zip File Confirmation
Decryption of file in GUI
1. Try opening the zip in GUI. Notice the LOCK-ICON next to file. It will prompt for password, Enter it.
Decryption of File
2. When successful, it will open the file for you.
Decryption Confirmation
That’s all for now. I’ll be here again with another interesting topic. Till then stay tuned and connected to Tecmint. Don’t forget to provide us with your valuable feedback in the comments below. Like and share us and help us get spread.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How to Encrypt Files in Linux
Keep your information safe from prying eyes
Linux offers several useful tools to encrypt files and protect your data from prying eyes. For example, you can use gpg to encrypt files. Some of these tools are built into the operating system, and some must be installed. Here are four methods that can hide your data away.
Hide Files With File Manager
The first method doesn’t employ any encryption or password protection. It relies on a feature of the Linux file-display logic to hide something in plain sight.
Open the default file manager for your distribution, then go to the location where you want to hide a file or folder.
Right-click an empty spot in the file manager, then click New > Folder.
When prompted, give the new folder a name, but make sure it begins with a period. For example, to name the folder documents, name it .documents.
In Linux, folders that begin with a period are called hidden folders and aren’t displayed, by default, in the file manager or from the command line.
If you can’t see hidden folders in the file manager, press Ctrl+H. You should then see all of the hidden folders and files within that directory (including the new one you created).
Move files you want to hide to the new folder.
Use Encryption Software
The next method makes use of encryption software. The command used for this is gpg, which is installed on most Linux distributions. Here’s how to encrypt the file
Open a terminal window, then change to the Documents directory with the command:
When prompted, type and verify an encryption password.
You now see a new (encrypted) file, named test.docx.gpg. That new file cannot be opened without decryption.
Decrypt the .gpg file with the command:
You are prompted for the passphrase you created during the encryption. Type that passphrase to decrypt the file.
If you didn’t move or delete the original file, gpg asks if you want to overwrite the new file or give it a new name. For your first attempt at encrypting and decrypting, either move the original file (before decrypting) or give the newly decrypted file a different name. Once you have the hang of encrypting and decrypting, you can delete the original file after you encrypt it.
When prompted, type and verify an encryption password.
You can now open the encrypted file.
Encrypt Files with a GUI
If you prefer using a graphical tool, and you use a distribution that includes the Nautilus file manager (such as Ubuntu Desktop), encrypt and decrypt files with a simple right-click on the target file. Here’s how:
Open a terminal window, then issue the command:
Open the file manager, then go to the directory that contains the file you want to encrypt.
Right-click the file to be encrypted, then click Encrypt.
In the next window, click Use a shared passphrase.
When prompted, type a new passphrase for the encryption. You’ll be asked to type this passphrase twice.
You should now see the newly encrypted file in the folder.
How to Decrypt Individual Files
To decrypt a file from the file manager, follow these steps:
Right-click the file, then select Open With Decrypt File.
When prompted, give the file a new name, then click Save.
When prompted, type the encryption passphrase.
How to Encrypt a Folder
Encrypt folders using the file manager or the gpg-zip command. The process of encrypting folders in the file manager is the same as encrypting single files. The only difference is that you’re asked if you want to encrypt the files individually or together in a package.
To encrypt a folder from the command line, use the gpg-zip command. Here’s how:
Encrypt, for example, the Documents directory, with the command:
The -c option instructs gpg-zip to encrypt. The -o option indicates what follows is the output (or resulting file name) for the encryption.
When prompted, type (and verify) an encryption passphrase.
You can then decrypt the encrypted folder in the same method you decrypted the file with the command:
Источник