Password Protect Zip Files in Mac OS X

Jan 7, 2012 - 55 Comments

Password protect a zip file archive Creating a password protected zip file is easy in Mac OS X and does not require any add-ons or downloads. Instead, use the zip utility that is bundled with all Macs.

This offers a simple way to protect a zip archive file from unwanted viewing access, as when a user attempts to decompress the contents of the zip archive, the correct password must be entered in order for the archive to extract.

How to Password Protect a Zip File from Mac OS X Command Line

If you’re familiar with the command line, the syntax of the encrypted zip command is as follows:

zip -e [archive] [file]

For encrypting multiple files with a password, such as folder or an entire directory, the syntax would be as follows:

zip -er [archive] [folder]

If you’re not sure how to use that, read on to learn how to create zip archives encrypted with passwords. These encrypted zip files will maintain password protection across platforms, meaning you can send a protected zip file to a Windows user and they will still need to enter the password in order to view the contents.

Zip Password in Mac OS X

Set a Zip Password in Mac OS X

You can create password protected archives of files and folders:

  1. Launch the Terminal from the Applications > Utilities folder
  2. Type the following command:
  3. zip -e filetoprotect.txt

  4. Enter and verify the password – don’t forget this

The resulting archive, in this case named “”, is now encrypted with the password provided. The file that was encrypted, “filetoprotect.txt”, is now inaccessible without entering that password.

If you plan on compressing multiple files within a folder, you will want to slightly modify the command with the -er flag like so:

zip -er /path/to/directory/

This is particularly important for encrypting zips of multiple files under OS X Mavericks.

Example: Zipping a Folder and Setting a Password

Here is an example of what this will look like from the command line, in this case we are compressing and password protecting the entire ‘Confidential’ folder located within the users /Documents directory, and the password protected zip is being placed on the users desktop for easy access:

$ zip -er ~/Desktop/ ~/Documents/Confidential/
Enter password:
Verify password:
adding: ~/Documents/Confidential/ (deflated 13%)

Notice the password will not display, this is normal behavior for the Terminal.

Notice that with a folder of multiple files, you will want to use the -er flag, the addition of the r indicates that zip will recursively compress and password protect all files in the folder.

Opening the Password Protected Zip

Despite being created at the command line, you do not need to unzip the file from the terminal, it can be expanded from the Mac OS X Finder or within Windows using standard unzipping apps. Just double click on the file, then enter the password, and it will decompress. You can also decompress the zip archive from the command line with:


Here are some use cases for password protected zip archives:

  • Password protecting an individual file or directory
  • Sending a sensitive and encrypted file over an unencrypted network
  • Emailing confidential data to a Windows user
  • Adding an additional layer of security to a hidden folder
  • Password protecting your own backups, outside of Time Machine

While this can provide some protection on a per-file or folder basis, it’s always a good idea to password protect the Mac in general with a login requirement on system boot, wake from sleep, and waking from the screen saver.

Keep in mind that password protected zip files are not encrypted with some super strong deep encryption method, so if you want a more secure file encryption, you may want to pass a regular zip file through openSSL encryption with des3 or something similar to really make the file secure.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Security, Tips & Tricks


» Comments RSS Feed

  1. Kaiser says:

    Good tip for casual use. Using openssl for encryption would be a better choice for anything truly sensitive to prying eyes.

    openssl des3 -salt -in regular.txt -out encrypted.txt

    openssl des3 -d -salt -in encrypted.txt -out regular.txt

  2. Steve says:

    on Snow Leopard, zip -e works fine, but double clicking to decrypt does not, I get a not permitted error. Meanwhile on my Lion machine I get a file of zero length when Unarchiver is finished ie only the encryption part of this is working

    • Titans says:

      Unarchiver might be screwing it up, the bundled Archive Utility opens these without incident.

      Everything works as described here, OS X 10.7.2

      • Jax says:

        doesn’t work on Mavericks.creates the file but when I try to unzip it there is only an empty folder with no content + doesn’t ask for password during unzipping.

        • PH says:

          Password protecting zips does indeed work in Mavericks, you must follow the instructions. Passwords for the zip files are automatically saved, thus it won’t ask for the password unless you choose NOT to save the password when entering it.

        • Steve says:

          One condition that will cause an empty archive: If the user operating the ZIP utility doesn’t have permission to read from and write to the folder being compressed. Before ZIPping, set the permissions for the folder so that you, the user, can read and write (in the Get Info panel).

    • Rachael says:

      I have Lion as well, instead of zip -e use zip -ejr. The “e” option stands for “encryption,” the “j” for “junk the path” (otherwise the zip command will archive the complete folder hierarchy leading to your target folder, which you probably don’t want), and “r” stands for “recursive,” which will force the zip command to include the entire contents of the folder in the archive. (Otherwise it will only archive the folder itself without its contents, which is not exactly useful.)

      • Bob A says:

        In Lion (10.7.4): For a single file, I successfully used:

        zip -ej originalfile

        It does seem that the original file name has to include the path or the file can’t be found. The easiest way to do that is to drag the original file into the Terminal window after the ‘’ — Terminal will put in the path and file name.

        It created an encrypted zip file that opened just fine. However, the encrypted file was saved in the top level of my User folder. Two questions:

        • Is there any way to create the encrypted-zipped file and have it land in the same location as the original file?
        • Can Windows users open the resulting encrypted-zipped file?

  3. Steve says:


    works fine

  4. René Dubois says:

    Double-clicking or using the unzip from command line works for myself.

  5. Jim says:

    Seems easier to just use Stuffit, Unarchiver, or any number of the other free GUI utilities out there.

    Don’t get me wrong, nice to have options.

  6. rotundus says:

    I keep getting “zip error: nothing to do!” as a response. I don’t see how I could be messing this up, but apparently I am. Any ideas why?

    • Will says:

      As a response to what specifically?

      zip -e file_to_zip.txt

    • jess says:

      I’m getting the same response “zip error: nothing to do”. Is there a remedy to this?

    • Steve says:

      Yes, you need to specify the full path to the file you’re trying to ZIP and it cannot have any blank spaces in it. So if the file is in a folder named, for example, “This and That,” change that folder’s name to “This-and-That” and then specify the full path to it (for example, ~/Documents/This-and-That/fileToCompress.doc, not just fileToCompress.doc).

  7. Jack says:

    Silly question, but what about just making a standard zip file? How do you do that?

  8. […] wondered how to make a zip file in Mac OS X? We recently demonstrated how to password protect zip archives, but in the comments a reader asked a more simple yet completely valid question: “what about […]

  9. Chris says:

    Feeling sheepish; have tried zip/pw many times for files and folders and receive this error:

    [Chris-MacBookAir:~] christopherrollyson% zip -e ~/Documents/Resources/TechSupt/ ~/Documents/Resources/TechSupt/test4zip.rtfd
    Enter password:
    Verify password:
    updating: Users/christopherrollyson/Documents/Resources/TechSupt/test4zip.rtfd/ (stored 0%)
    [Chris-MacBookAir:~] christopherrollyson%

    It creates an empty zip every time. Help? TIA

  10. Joe says:

    Got Lion und have a similar problem.
    Got a valid zip file with option “-e” after entered a password.
    But the status message is “stored 0%”!

    The zip file is not! encrypted and more the twice as big as the normal zipped file with the finder.

    Does anyboby no what I make wrong?
    thanks for help!


  11. TJ says:

    I’m in Lion and the compression works fine. It asks for the password and verify and zips the file. When I double click on the zip file it just opens without asking for a password.? I guess I’ll look for some archiving software that has password protection.

  12. TJ says:

    What? There is no option to save the password in the keychain in Terminal that I am aware of.

  13. mym says:

    hi i try to follow this .. but after pasting zip -e filetoprotect.txt i can’t proceed typing the password.. well i type a pw but the cursor doesn’t move at all. what am doing wrong?

  14. Eve says:

    Hello how do you unzip from command? I try double clicking the file with a password protected zip file, but it doesn’t work. Thank you.

  15. ps says:

    hello. also confirming this does not create a password protected archive in lion just as TJ discovered. there is no checkmark for “save password” in the command line. so… what do we do?

  16. ps says:

    quick followup – the original post instructions do not work, as mentioned. however, following rachel’s instructions above, using “-ejr” instead of only “-e” worked just fine in lion. archive was encrypted.

    only negative – i use “the unarchiver” as my unzip utility – this password protection froze it. but, the default mac utility works fine.

    you’d think something as simple as zip password protection would be easily implemented into the OS, and on top of that would be compatible. i mean, come on apple!

  17. rb says:

    In snow leopard, the archive is created, but double clicking on it throws an Error 1 – Operation Not Permitted.

  18. smayton says:

    Lion: In Terminal, I simply get:

    -bash: $: command not found

    • Kit says:

      The trick is not to include the dollar-sign ($) when you’re copying the command above. The dollar sign is shown in the Terminal before each command you type and so that’s why it’s shown up there.

      So the command you need is just:

      zip -er “My output” “The file/folder I want to ZIP up”

      (the “r” after the “-e” just means to also ZIP up any contents of a folder if you specify one; that’s necessary to ZIP up a folder—password or not—at least on Lion).

  19. I have an archive that has been created and encrypted on a PC, which contains three different files, one of them with a different password. Under Lion, if I simply double click on it, I get Error 1 – Operation not permitted.

    With terminal, I can unzip with
    unzip filename.rtf
    after providing the password when prompted, the file is extracted fine.

    Terminal remains a rather cumbersome tool for users who do not know commands…

  20. scarlet says:

    In Snow Leopard I had to type cd ~/Desktop (it is on my desktop) in order to make this work, it didn’t find the file just from including the pathname with the filename….

  21. Adam says:

    zip -ejr ~/Desktop/FolderToBeZipped.Zip /FileLocation/File.ext

    drag and drop the file from the location to the right side of the zip -ejr ~/Desktop/FolderToBeZipped.Zip. Delete any spaces from the drag and drop

    This works in Mac OSX 10.7 Lion

  22. leetut says:

    zip -e DVD_VR.mp4


    zip warning: name not matched: DVD_VR.mp4

    zip error: Nothing to do! (

    cant seem to find anything in the ‘guide’ about what to do when that happens, so ill consider it total junk

    • Kit says:

      This is because you’re trying to ZIP the file while not in the correct directory in Terminal (when you open a Terminal window it opens to your home directory, not the current folder you’re in in Finder). There are two ways you can solve this:

      1. Once you have Terminal open, use the “cd” command to change to the folder the file is in. The easiest way to do this is to write “cd ” (that is, type c, then d, then space), then drag the folder your file is in over the Terminal window and press Return. That tells Terminal to “change directory” to the folder you dragged in.

      Or, alternatively:

      2. Instead of just writing the filename, you can put the full path to the file instead. The easiest way to do _that_ is to drag the file itself onto the Terminal window instead of typing out its name. So then the steps would be to type “zip -e ” (including the space) and then drag your file into the Terminal window, then press return.

      The ZIP file will go into the folder you’re currently in in Terminal (so if you don’t change to the directory your file is in first, your ZIP will actually be put in your home directory.

  23. Guhan says:

    I wanted to zip a folder (that had subfolders) with a password using only OSX (10.8 Mountain Lion). Had similar problems to those detailed above. For me this worked:

    zip -er sourcefolder

    As mentioned in the article, when typing the password, the cursor will not move (typical when working in the terminal). Type as you would normally, hit enter, then confirm the password by typing it a second time (cursor won’t move).

  24. dstreitfeld says:

    In order to zip the contents of a folder, it’s not enough to just specify the folder name, or you will indeed get an empty zip file. You need to include an asterisk as follows…

    zip -e ~/Desktop/ ~/Documents/myfiles/*

  25. gyffes says:

    Thanks for this, just used it with great success.

    My steps:

    1) Open Terminal;
    2) typed “cd” a space and then dragged the folder containing the files to be compressed into the terminal window;
    3) unsure if this would do entire folders, I typed
    “zip -e File1.xls” (no quotes)
    and was asked for pwd 2x
    [NOTE: terminal does not show movement when typing pads.. just trust that it’s being entered!]
    4) typed
    “zip -e File2.xls” (no quotes)
    and was asked for pwd 2x
    5) typed
    “zip -e File3.xls” (no quotes)
    and was asked for pwd 2x
    6) MOVED the folder to a different location;
    7) Double-clicked the archive and was asked for pwd.

    Voila, folder created on my desktop with the three (3) files inside (I wasn’t sure if it was adding to the Archive or over-writing.. now we know — it was adding!).

    Again, my thanks!

  26. […] app that is free, fast, and efficient, and does exactly what we want it to do, plus it handles password protected zips with ease. The only complaint is the developers haven’t yet updated the app for the […]

  27. […] accessible, like a safe, in addition to somewhere safe in the virtual world, be it in a password protected zip file in a web mail account sent to yourself, or somewhere else with multiple security layers that […]

  28. […] situations where more security is needed, and for groups of files that need password protection, a protected zip archive is a great way to go, and it also adds a level of file compression which makes it ideal for remote […]

  29. […] The zipinfo command will only work for zip archives, and it will not view the contents of password protected zips. […]

  30. Lauren says:

    I tried and tired to do this with mavericks, and it kept giving me a 0% file. Then I found this website, with the same instructions except their command line starts “zip -er” instead of “zip ‘e”. It worked like a charm.

  31. Claus says:

    hi all, the article above says: “These encrypted zip files will maintain password protection across platforms, meaning you can send a protected zip file to a Windows user and they will still need to enter the password in order to view the contents.”
    I cannot confirm that password protection is working cross platforms.
    I have used the terminal command “zip -er [archive] [folder]” as advised above under OS X Mavericks. A password protected was created as expected. To extract the ZIP-file in Mavericks I had to enter the password as expected. But the I moved the ZIP-file to Dropbox and downloaded it with Windows Vista. Clicking the ZIP-file showed immediately the files in the contents of the archive, without any need to enter a password.
    Trying to open one of the files in the content caused a window to open asking for the password (on file-level not on archive-level). After I entered the password as used for creating the archive under Mavericks resulted in an error message like “the file cannot be opened, it may be damaged”. Using Microsoft OneDrive instead of Dropbox resulted in the same behavior. I am too lazy to test now the other way round, if I would create a password protected ZIP-archive in Windows and send this one to Mavericks but I would expect this way to work. My conclusion: it seems like the Apple way does not keep the conventions.
    Regards, Claus

    • Barry says:

      ZIP is a generic archive format that is readable by OS X, Windows, Linux, and many other platforms. An archive made in one operating system is able to open in other operating systems, whether it is password protected or not. Be sure the file did not get corrupted in the transfer process, and be sure to use a compatible zip archive opener utility (on Windows you can try something like WinZIP if you have troubles)

    • Hal9000 says:

      Had the same precise situation with Yosemite.

  32. Adam says:

    I too am having problems making this work in Snow Leopard. I can successfully create an encrypted ZIP file of a PDF. And I can successfully unzip using Terminal and entering my password. However I cannot simply double click the ZIP file for it to unzip. I get an error (Error 1 – Operation not permitted). This leaves me to believe it is a Permissions problem, as suggested above. The permissions for my Desktop are read only for everyone other than the owner (me). How and where should I store the PDF and subsequent ZIP to allow full permissions. I dont want to get into messing around with Desktop permissions, it’s a slippery slope to never ending problems in my experience.

  33. Eric Sebasta says:

    What I want is an automator workflow finder addon that allows me to right click a zip and add a password.

  34. Sorry, this isn’t working for me: here’s the text of my attempt:

    Mikes-MacBook-Pro:~ xxxxx$ zip -e filetoprotect.txt
    Enter password:
    Verify password:
    zip warning: name not matched: filetoprotect.txt

    What have I done wrong here?

    • PReinie says:

      Mike Flugennock (and anyone else who cares) in the same terminal window where you entering the zip command, at the prompt enter “ls filetoprotect.txt” (minus the quotes) and if you get “no such file or directory” that means you are not in the directory (“folder”) where the file is.

      You have to cd (change directory) to where the file is or specify the full path. If there are spaces in the path surround the entire file name with double-quotes (“) or put a backslash ‘\’ before each space as in file\ to\ protect.txt for “file to protect.txt”.

      Better yet, before you hit return (enter) type the Tab key. Terminal will beep at you if it can’t find a file matching the name. As a matter of fact, if you type “zip -e filetopr” (minus the quotes and then type the Tab key if the file exists Terminal should fill in the rest of the name for you assuming only one match or it will beep if more than one file matches.

      (Note, above, ls is lowercase el, lowercase ess as in the first and third letter of list – not the numeral one ‘1’ which depending on the font might look the same… and terminal requires the correct character case.)

      Sorry, that’s a lot of info to digest – and I only come here when researching so if you ask I may not reply.

  35. darius says:

    worked like a charm, thanks! great way to send tax info around. kinda makes me feel like a paranoid ninja, but you know what they say about an ounce of prevention…

  36. Jo says:

    Didn’t work at all for me on OSX Yosemite. Not with the full path to the file, nor with cd to it’s directory. Got three error messages in the terminal:

    zip warning: missing end signature–probably not a zip file (did you
    zip warning: remember to use binary mode when you transferred it?)
    zip warning: (if you are trying to read a damaged archive try -F)

  37. Richard says:

    The problem with all of these password procedures is that gmail will not allow you to attach a file that is a zip file within a zip file.

    Compressing the file first and then password protecting it causes gmail to see it as a zip file within a zip file and it won’t let you attach it.

    Installing keka worked for me.

Leave a Reply


Shop for Apple & Mac Deals on

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates