Create encrypted (password protected) zip file
Solution 1
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.
Note, Use -r
to zip directory and subdirectory recursively.
Solution 2
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.
Solution 3
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
Solution 4
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 7zip -
a
: Append? / Adding files? (e
for extraction) -
-tzip
: Use .zip format instead of default .7z -
-mem=AES256
: Use AES256 encryption -
foo_file.zip
: Name of .zip file -
foo_folder
: Name of folder to encrypt
Answer based on: https://www.tecmint.com/7zip-command-examples-in-linux/
Solution 5
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
Related videos on Youtube
vishal
Updated on September 17, 2022Comments
-
vishal over 1 year
How do I create an encrypted (password protected) zip file?
-
Byte Commander about 9 years
-
rubo77 about 6 yearsNote, that Zip Passwords is no protection! those can be easily broken! use 7-Zip with a long password instead, or better GNUPG encryption!
-
domih over 5 yearsgnupg is the answer
-
-
vishal over 13 yearsIs there a better option from the standard encryption?
-
Jesse Purdy over 13 yearsUsing gnupg on the final zip with a key for yourself or your destination.
-
Xeoncross about 12 yearsIt's worth noting that you need to install
.rar
before you can use it in the compressor. -
Black over 6 yearsDoes not work
file.zip
is empty -
Jonathan over 6 yearsI don't see "Other Options" anymore in Ubuntu 17.10 (I remember seeing it in earlier version though)
-
H G Sur over 6 years@Black If you're trying to compress a folder, then you need to use
-r
switch. So it'll bezip --encrypt file.zip -r your_folder
-
Ciprian Tomoiagă almost 5 yearscan this be extracted by any unzipping software ?
-
NumesSanguis almost 5 yearsI 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.
-
Budi Mulyo over 4 yearsis it compatible with windows, if recipient is wondows user ?
-
Arsinclair almost 4 yearsIf 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'
. -
syockit almost 4 yearsWindows zip folder does not support AES256. 7-zip or WinZip (maybe WinRAR too?) should be able to extract it.
-
X. Liu over 3 years@BudiMulyo Yes. It's compatible with Windows.
-
caw almost 3 yearsUnfortunately, this is the only option right now. But it’s not that many clicks more. Related: askubuntu.com/questions/868493/…
-
caw almost 3 years@Jonathan No solution, but related: askubuntu.com/questions/868493/…
-
Gabriel Staples over 2 yearsBest answer since it has good encryption. Double-clicking a file zipped in this manner in the
nemo
file manager at least (but probably on Ubuntu's defaultnautilus
file manager too) on Ubuntu allows you to open and decrypt via a GUI, making it very easy and intuitive for a recipient to decrypt on Linux Ubuntu.