Encrypt Folders with Password Protection in OS X the Easy Way

Aug 12, 2012 - 40 Comments

An encrypted and password protected image in Mac OS X can be created through Disk Utility

Encrypting folders and requiring passwords for access is an excellent way to store and protect private data on a Mac. Now, there is a new means of password protecting folders and sensitive files introduced in OS X with Mountain Lion that lets you create a new encrypted disk image directly from a specified folder. Though you can still create a blank disk image and fill it as you see fit by using the older trick, this new option in Disk Utility is easier to use and extremely quick, making it the preferred method to add a very strong layer of encryption to a folder, securing itself along with all of its contents.

Encrypting a Folder in Mac OS X

This specific “Image from Folder” trick requires OS X 10.8 or later to use:

  • Open Disk Utility, found in /Applications/Utilities/
  • Pull down the “File” menu and select “New” and then “Disk Image from Folder”
  • Create New Disk Image from Folder in OS X

  • Navigate to the folder you wish to turn into an encrypted drive and click “Image”
  • Set the Image Format to “read/write” and the Encryption to “128-bit AES”
  • Creating a new encrypted image out of a folder in OS X

  • Choose a strong password (or generate one by pressing the black key icon) and – this is important – uncheck the box saying “Remember password in my keychain”, then click OK

Setting password protection for the encrypted folder in Mac OS X

If you do not intend on using the encrypted image as a working folder that you can add and remove documents from, you can choose an Image Format other than “read/write”.

An encrypted disk image will be created based on the folder you specified, it may take a while if the folder is large or your Mac is slow.

Accessing the Encrypted Folder & Contents

After the encryption procedures is finished, you’ll now be able to access and use the encrypted folder. To summarize steps of accessing the encrypted folder and how to properly use it to maintain security:

  • Open the encrypted folder image with a double-click, treating it as a normal disk image
  • Enter the password used during the initial encryption setup – do NOT check “Remember password”
  • Accessing the encrypted folder in Mac OS X requires a password

  • Access the encrypted folder and the contents as a mounted virtual disk, you can modify, copy, edit, delete, and add to it
  • When finished, close the files and eject the virtual image to re-secure the folder and files and require a password for future access

You will want to locate the encrypted dmg file and store it somewhere accessible enough, since you will be using a double-click to try to mount the folder image in the Finder when it needs usage, and of course you will need the password to access the files. Just as when creating the disk image password, always uncheck the box saying “Remember password in my keychain” or else you will store the password and lose the security benefit of the encrypted image since anyone with access to your user account could open it. This also applies to transferring the encrypted folder image to another Mac.

With a readable and writable encrypted disk image, you can treat it as a normal folder and copy, delete, or move files from the image. Anything brought into the image while mounted will become encrypted automatically under the same protective layer with the same password. When you are finished working with the folder and want it password protected again, simply unmount the disk image. Regaining access again will require the password before it can be mounted and available.

The short video below demonstrates the entire process, in less than a minute you can encrypt a folder with password protection and mount it for access.

Remember, do not forget the password, or else you will lose access to the data stored within the encrypted folder for good. This is important, because the security level of the encryption format is so strong that it’s virtually impossible to break, thus a lost password means lost data.

Note: This will only encrypt and password protect the folder specified, if you are looking for full disk encryption for literally every single thing on the Mac, you would want to enable FileVault instead. FileVault applies similar encryption methodology to the entire hard drive automatically.

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 Mac OS X, Security, Tips & Tricks

40 Comments

» Comments RSS Feed

  1. faraz says:

    How can put an icon for folders as a default ? it means when I want to create a new folder , this icon come out!
    for mac!!:|
    tnx

  2. Aaron says:

    Good one Faraz! Since we’re venturing off topic, how do I get my Apple to grow fruit?

  3. Chris says:

    Getting back on topic briefly :-)

    Actually this is not new in Mountain Lion: works also in my Snow Leopard system, and I’m pretty sure it goes way back to the earliest days of OS X.

  4. Pbando says:

    Im just wondering what if I put the dmg to dropbox, this way i would able to store my company files securely in dropbox.

  5. Guy says:

    Okay, I’ve created an encrypted .dmg. The password works to mount a disk image. Great.

    But the original folder is still there will all the content, and this original folder is NOT encrypted!

    Am I supposed to trash the original folder?

    Also, how do I un-encrypt the .dmg file?

    • B30 says:

      Of course, you have to trash the original folder, otherwise it would be pointless. You don’t have to un-encrypt the dmg (you do know your password, right), just mount that thing, drag and drop your data out of it wherever you want it (erase it on the dmg, if this is what you want) and you’re done.

    • Mark says:

      Agreed. I would think the target folder’s contents would be placed in the image. Why else go to the trouble of making this “from a folder?” Space issues are not good either. Wouldn’t you expect to need a folder larger in the future than it is now? I will make a fresh encrypted image from Disk Utility, as I don’t understand how it is any advantage to make it modelled on a folder.

  6. B30 says:

    Of course, you have to trash the original folder, otherwise it would be pointless. You don’t have to un-encrypt the dmg (you do know your password, right), just mount that thing, drag and drop your data out of it wherever you want it (erase it on the dmg, if this is what you want) and you’re done.

  7. Aberto I says:

    Good trick!
    The problem is that if you create a dmg from a folder of 10MB, the dmg has a maximum capacity of 10 MB and it is not expandable, and so it is not possible to add new files to the dmg.
    Or is there a way to do that?

    • Dan says:

      No. The Create From Folder doesn’t let you do that. For an expanding disk image, you need to create a New Disk Image and specify the type as Sparse Bundle. You can choose to encrypt this and then you can copy stuff in to it. It will resize the image to hold the data.

  8. smrt says:

    I had an idea to encrypt whole home directory. I created a new user “encuser” account, then I created an encrypted dmg image. I mounted it as root user by commandline “sudo hdiutil mount -mountpoint /Users/encuser”.

    I swtiched user to encuser and it worked as I expected. However, when I was using the “encuser” acount for some time I realized, the encrypted disk was lagging. I/O time to time idled for even 10 secs. It was so much laggy so it was useless. Am I doing something wrong? On linux I can mount encrypted partition (or loopback file) and use it as my home directory with no problems. Why isn’t this possible on Mac?

    I also realized, when I had logged-out the user some of his processes were still runing. I had to “killall -u encuser -9″ to be able to umount the imege. WTF?

    • Jeb says:

      The built in File Vault feature turns the home directory into an encrypted disc image that is mounted and unmounted automatically.

      • Dan says:

        This is only true of Snow Leopard. Lion and ML use Filevault2, which uses whole disk encryption, not just the Home folder.
        Making your Home folder encrypted is a pain and causes numerous admin problems for OSX processes. Either turn on FileVault or use an encrypted image for your Documents. Don’t try to do it yourself; even Apple decided it wasn’t very good.

      • smrt says:

        I can’t use FileVault since several people use my iMac. If I use FileVault all of them would have access to the whole disk.

        Btw, there is a very basic security problem with dmg encrypted images. Consider your mac is confiscated in UK. They found encrypted *.dmg file on your disk and because of the law in UK they force you to reveal the password (keeping you in jail). You have a same problem with FileVault. IMO, truecrypt is much safer since there is no way how to prove the file named “random-data.dump” is encrypted disk image.

  9. Robert says:

    All goes well to the point where I click on the newly created .dmg (i.e. 0.56 secs on your video).
    It ‘flashes’ but the box asking for the password does not appear so basically nothing happens and can’t proceed.
    Obviously done something wrong but not sure what.

  10. Paul says:

    Errrr….the title of this article says “…the Easy Way”. This is not easy. I have, for so long, wished theat crappy old Mac OSX would have a “right-click, select “encrypt folder”” option. Type in a password…the folder’s encrypted. To open it, you’re prompted to type in the password again. Is this beyond the capabilities of Apple programmers? Apparently so.

    • Lincoln Sills says:

      Are you reading what you are writing? You, in a very condescending manner, trash the post saying “This is not easy”, and then you trash Apple saying they are incapable of encrypting a file…but it’s right there in front of you AND this is easy. LOL That is the most ironic post I have ever read here.

      • Richard says:

        Actually, he’s right. This whole thing could be made much easier and user-friendly. It’s a case of Apple dropping the ball, or, more likely, correctly assuming the bulk of its users are typically Homers who use iPhoto and Twitter but don’t bother with more arcane and complex operations.

        If Apple wants to use some of its great wealth to simplify and streamline the process, the clunky Disk Utility should be removed from the equation. Additionally, little clumsy infelicities need cleaning up.

        For example, it’s simply stupid to have to unclick the option to store the pw in one’s keychain every single time. How many times must I tell OS X this?

        Additionally, you can’t see the password you’re typing as you create the encrypted file — an option to do so is only there when you decrypt. Again, this is too clever by half, since it’s obviously meant to hide the pw from prying eyes. But what genius at Apple decided only encryption, and not decryption, should be sooper-sekrit? Or as you would put it: LOL.

  11. Lamar J says:

    Strangely, I noticed once this is done, I cannot delete files inside the new dmg.

    Yes, I have opened the .dmg using the password. Yes, I have checked permissions and have read/write access.

    Like Dan as said I recommend using the sparse bundle. I have had success with this method, strangely I think it is easier and it is expandable and more importantly, shrinkable. Back to the old way.

  12. Brian H says:

    I wonder why nobody uses an encrypted ZIP file from terminal anymore.

    Just use this syntax:

    zip -erm folder.zip folder where folder is the files you want to encrypt.

  13. Francis says:

    I have been using encrypted disk image for long time; since OS Leopard. And I have no problem with it. Currently I’m using OS Mountain Lion and now I have problem with it. The Encrypted disc image which is created in this latest OS becomes so slow when I copy files to it. Does anybody have experienced this problem? Does anybody know what is the problem and how to solve it?

    Thanks

  14. ThomasYH says:

    Ok. so if i make disk image and place it on my desktop. I use it for a wile. Then i want to delete it/ free the space from my computer. How do i delete or free the reserved space? Do i only drop the disk image in the trash? Does that free my hard drive from the disk image? Or does it only delete the img and the space is still reserved on my hdd??

  15. Phil says:

    This article is very interesting! However, beside “Documents” folder, how we can put security password to another folder? Thanks.

  16. Henry says:

    Hey what am I doing wrong. I followed all the instructions to password encrypt a folder on my Mac It creates the dmg folder, but when I click on the dmg folder it does not open & as for password. IT actually does nothing. WHat did I do wrong ? Also can you use the same process to change the password on a protected folder.

    Thanks

  17. Kris says:

    This is a terrific tutorial. I’ve been looking for a simple tool to encrypt work files, and this is it! I’m so happy I don’t have to download some application… Thank you!

  18. Chris Q. says:

    You cannot use a crypted folder that way since you cannot add new files to the folder. The folder size is fixed and CAN’T BE EXPANDED.

    • Matt says:

      You can add new files to the encrypted folder by unlocking the DMG and then copying files to it. If you intend on placing a lot of files in there, make sure to account for the growth in file size when creating the original disk image. You can also use Disk Utility after the fact to resize an image if necessary.

      You can think of the encrypted disk image folder as a little virtual hard drive partition, it is set in size just like a partition but can be shrunk or expanded if necessary.

  19. Manas says:

    this is very very helpful in keeping privacy and very good. this can actually lessen your burden if you have any doubt that someone might see your files.

  20. Eugene says:

    This works great with one exception. It appears that anyone can delete the DMG file even if they can’t access it. So if the point is to protect it not only from other users accessing it but also deleting it then this doesn’t work. Any suggestions? I have one user name and other user occasionally use my computer. Even though they couldn’t see the contents in the directory with the password they could drag the image file to the trash and empty it.

    Would love any advice.

  21. Sam says:

    I’ve used this to make an encrypted file… however when I try to add more files to the encrypted folder it doesn’t work… theres not enough room.

    anyone know how I can add to my encrypted file or make it larger? i just want to avoid having to redo this process every time i want to add to the file.

    Thanks!

  22. Scott says:

    Im mediocre with computer terms so dont kill me:

    I made a ‘disk image from folder’ called “Scotty’s Folder” and placed the link into another folder “Business Folder”.

    In order to access “Scotty’s Folder” I had to:
    1)Open Business Folder on desktop
    2) double click blahblahbah.disksparseimage (or something like this)
    3)enter password
    4)Then “Scotty’s Folder” appeared

    …..But I recently deleted “Business Folder”. I my secret “Scotty’s Folder” gone?!?

  23. Cris says:

    I was able to create and mount the DMG, but I can’t move anything into it, even though the sharing and permissions on the DMG say I can read and write. When I’m in the mounted drive in Finder, it won’t let me create a new folder in it. Any suggestions?

  24. razz says:

    Upon trying to create the image with the encryption I receive a message saying: “Unable to create “Storage B.” (Permission denied)” Any idea what is wrong?

  25. josh says:

    so i made one but when i put things into the trash it dosent let me delete it says. “The operation can’t be completed because you don’t have permission to access some of the items.”

  26. Gertone says:

    I have a tremendous problem. I created a .dmg in order to put some special stuff in there. It had a strong password, but today I tried to open it and it says that the password is wrong. I don’t know where this come from. The password I’m using is the correct one… I need those files so bad. What can I do?

    Thanks.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

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