Suppose you want to create a zip archive, but with password protection, so that whoever tries to uncompress the zip file must know the right password. On Linux, there are several ways to encrypt and password protect a zip file.
In this tutorial, I will describe how to create an encrypted zip file on Linux.
The zip command line tool provides an encryption option. The encryption algorithm used by zip command is PKZIP stream cipher. The PKZIP algorithm is known to be insecure. Also, the fact that the password is typed and shown in plain text makes it even more vulnerable.
To create an encrypted zip file with zip:
To uncompress a zip file that is encrypted with zip command:
Archive: secure.zip [secure.zip] doc.pdf password:
7z file archiver can produce zip-format archives with more secure encryption scheme. According to the official description, 7z archiver supports AES-256 encryption algorithm with SHA-256 hash algorithm based key generation.
To create an encrypted zip file with 7z archiver:
To uncompress a zip file that is encrypted with 7za command:
7-Zip (A)  9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,8 CPUs) Processing archive: secure.zip Extracting doc.pdf Enter password (will not be echoed) :
Another way to create a secure zip archive is to use GnuPG's symmetric key encryption.
To create an encrypted compressed tar archive with GnuPG:
To uncompress an archive file encrypted with GnuPG:
If you use Nautilus file manager on your Linux desktop, you can use Nautilus GUI to create a password-protected zip file easily.
First, highlight a set of files to include in the archive. Then right-click them, and choose "Compression" option.
Fill in the archive file name, and select ".zip" suffix (or ".7z" if you have installed 7z archiver). Click on "Other Options" and fill in your password. Underneath Nautilus, it will use zip command to create an encrypted archive.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to install Suricata intrusion detection system on Linux - September 3, 2015
- How to switch from NetworkManager to systemd-networkd on Linux - August 31, 2015
- How to set up a system status page of your infrastructure - August 25, 2015