Create a password-protected ZIP file on Mac OSX

Oh Dear monitors your entire site, not just the homepage. We crawl and search for broken pages and mixed content, send alerts when your site is down and notify you on expiring SSL certificates.

Start your free 10 day trial! »

Profile image of Mattias Geniar

Mattias Geniar, November 16, 2015

Follow me on Twitter as @mattiasgeniar

If you want to send someone a file of which the content you prefer to remain anonymous, you can send it in a password protected ZIP file.

It’s not 100% safe, it can still be brute forced and you probably shouldn’t be sending your banking details like this, but it can be useful to send along information this way.

To do so on a Mac, follow these steps (which should be easy if you’re familiar with the command line).

  1. Open your terminal/iTerm
  2. Go to your directory where you have the files/folders you want to zip: cd ~/Desktop/files/
  3. Create the encrypted zip:
    $  zip -P YourPass my_zip_file.zip your_original_file.docx
    adding: your_original_file.docx (stored 23%)
    

Note; if you type the zip command in your shell with an extra space before the command, it won’t be saved in your bash history! Since you’re typing the password directly as a command-line argument, it poses a security risk of staying in your history files.

The zip -P will be followed by the password for your ZIP file. The first argument after that is the name of your new, password protected, zip file and the second argument is the file or folder you want to encrypt.

Note: this article used to refer to the zip -e command. This seems safer as it prompts you for your password (instead of typing it directly as an argument to zip -P, but uses weak PKZip 2.0 encryption. The zip -P uses standard encryption.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.