Create encrypted (password protected) zip file
How do I create an encrypted (password protected) zip file?
Note, that Zip Passwords is no protection! those can be easily broken! use 7-Zip with a long password instead, or better GNUPG encryption!
gnupg is the answer
This will prompt for a password:
zip --encrypt file.zip files
This is more insecure, as the password is entered/shown as plain text:
zip --password (password) file.zip files
Warning, the standard zip encryption is very weak and is easily cracked.
Is there a better option from the standard encryption?
Using gnupg on the final zip with a key for yourself or your destination.
Does not work `file.zip` is empty
@Black If you're trying to compress a folder, then you need to use `-r` switch. So it'll be `zip --encrypt file.zip -r your_folder`
is it compatible with windows, if recipient is wondows user ?
You can also right-click on a folder or file(s) in Nautilus and select "Compress...". In the resulting window, you can expand the "Other Options" section to enter a password.
If the password field or any of the other options are not enabled, then the selected compression option does not support it. Select a different one from the list after the filename. According to the documentation:
Currently, only 7-Zip, ZIP, RAR and ARJ archives support encryption
It's worth noting that you need to install `.rar` before you can use it in the compressor.
I don't see "Other Options" anymore in Ubuntu 17.10 (I remember seeing it in earlier version though)
Starting from Ubuntu 17.10, right-clicking and selecting "Compress" no longer has "Other Options" listed.
To resolve this, open "Archive Manager" and then drag & drop the files/folders from your File Manager into it and it will appear.
If Archive Manager is not installed (as in my lightweight debian for example), it can be installed with `$ su root -c 'apt-get install file-roller'`.
Comments and answers have mentioned the default zip encryption is weak, but since there is no code example, here is on with .7zip:
sudo apt-get install p7zip-full # install 7zip 7za a -tzip -p -mem=AES256 foo_file.zip foo_folder # encrypt folder
Commands explained:
7za
: Use 7zipa
: Append? / Adding files? (e
for extraction)-tzip
: Use .zip format instead of default .7z-mem=AES256
: Use AES256 encryptionfoo_file.zip
: Name of .zip filefoo_folder
: Name of folder to encrypt
Answer based on: https://www.tecmint.com/7zip-command-examples-in-linux/
can this be extracted by any unzipping software ?
I think the resulting .zip is the same as using software on Windows to create a .zip with a password. I haven't experienced anyone telling me they couldn't unzip this, but I haven't used it often.
sudo apt-get install zip zip -r --encrypt result.zip folder
- Install zip
- Use
-r
to zip directory and subdirectory Use
--encrypt
to secure your fileswith a simple password-based symmetric encryption system, which is documented in the ZIP specification
Encrypt
gpg -c your.zip
creates
your.zip.gpg
Decrypt:
gpg your.zip.gpg
More details including directories.
License under CC-BY-SA with attribution
Content dated before 6/26/2020 9:53 AM
Byte Commander 5 years ago
Related: Compressing folders with password via command line