Create encrypted (password protected) zip file

255,398

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.

alt text

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
  1. Install zip
  2. Use -r to zip directory and subdirectory
  3. Use --encrypt to secure your files

    with a simple password-based symmetric encryption system, which is documented in the ZIP specification

    Wikipedia

Share:
255,398

Related videos on Youtube

vishal
Author by

vishal

Updated on September 17, 2022

Comments

  • vishal
    vishal over 1 year

    How do I create an encrypted (password protected) zip file?

    • Byte Commander
      Byte Commander about 9 years
    • rubo77
      rubo77 about 6 years
      Note, that Zip Passwords is no protection! those can be easily broken! use 7-Zip with a long password instead, or better GNUPG encryption!
    • domih
      domih over 5 years
      gnupg is the answer
  • vishal
    vishal over 13 years
    Is there a better option from the standard encryption?
  • Jesse Purdy
    Jesse Purdy over 13 years
    Using gnupg on the final zip with a key for yourself or your destination.
  • Xeoncross
    Xeoncross about 12 years
    It's worth noting that you need to install .rar before you can use it in the compressor.
  • Black
    Black over 6 years
    Does not work file.zip is empty
  • Jonathan
    Jonathan over 6 years
    I don't see "Other Options" anymore in Ubuntu 17.10 (I remember seeing it in earlier version though)
  • H G Sur
    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 be zip --encrypt file.zip -r your_folder
  • Ciprian Tomoiagă
    Ciprian Tomoiagă almost 5 years
    can this be extracted by any unzipping software ?
  • NumesSanguis
    NumesSanguis almost 5 years
    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.
  • Budi Mulyo
    Budi Mulyo over 4 years
    is it compatible with windows, if recipient is wondows user ?
  • Arsinclair
    Arsinclair almost 4 years
    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'.
  • syockit
    syockit almost 4 years
    Windows zip folder does not support AES256. 7-zip or WinZip (maybe WinRAR too?) should be able to extract it.
  • X. Liu
    X. Liu over 3 years
    @BudiMulyo Yes. It's compatible with Windows.
  • caw
    caw almost 3 years
    Unfortunately, this is the only option right now. But it’s not that many clicks more. Related: askubuntu.com/questions/868493/…
  • caw
    caw almost 3 years
    @Jonathan No solution, but related: askubuntu.com/questions/868493/…
  • Gabriel Staples
    Gabriel Staples over 2 years
    Best 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 default nautilus 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.