How to Install Encfs and Encrypt Files in Mac OS X

Encfs is an open-source software that is widely used to create encrypted filesystem. It is particularly useful for encrypting files that you want to store in the cloud, such as Dropbox or Google Drive. Using encfs in Linux and Windows is pretty straightforward as there are installers for both platforms. However, for Mac OS X, installing encfs is not as easy as it should be. Here is how you can install and use encfs in Mac OS X.

There are a number of ways to install encfs in Mac OS X. In this tutorial, we will show you the homebrew and OSXfuse installation method. It will require the use of terminal, so be prepared to get your hands dirty.

Homebrew is a useful package manager for Mac OS X. It allows you to install plenty of applications with a single command.

1. Open Terminal in Mac OS X. If you are not aware of where it is located, you can find it at “Applications -> Utilities -> Terminal”. Type the command:

This will install Homebrew in your system. If you have already installed Homebrew, you can ignore this step.

To install encfs (in El Capitan), simply run the command in the terminal:

Once the installation is completed, you will have encfs running in your system.

Still in the terminal, you can create an encrypted filesystem in Dropbox using this command:

Go through the setup process. You will be prompted to enter a master password. Make sure you use a strong password and remember it. Once completed, you should see a “Private” folder in your Home directory. Any file you place in this folder will be encrypted and stored in the “Dropbox -> Private” folder.

It is very troublesome if you have to mount the encrypted directory everytime you login. Use the steps below to automount the encrypted directory when you login.

1. Open “Keychain Access”. We will be adding your encfs master password to Keychain so the script can automount the encrypted directory without prompting you for password. Add a new entry. Enter “encfs” for both the “Item name” and “Account Name” field. Once you have added the password, you can close Keychain Access.

encsfs-add-password-keychain-access

2. Open a text editor and copy the following text into it.

Save the file as “encfslogin.sh” in your User directory.

Make the script executable:

3. Next, open AppleScript editor and paste the line:

encfs-create-applescript-application

and save it as an application in your User directory.

4. Lastly, go to “System Preferences -> Users & Groups”, click on your User account and select “Login items”. Add the encfslogin application to the startup list.

encfs-add-to-startup

Log out and login again. Your encrypted directory should be auto-mounted now.

Image credit: security concept with a lock by BigStockPhoto

12 comments

    • Did you install osxfuse? The encfs module installed by Homebrew is based on fuse4x and it seems to has a compatibility issue.

  1. That’s a great tutorial, but it’s missing a point – how do you open a previously encrypted file? That is, how do you decrypt?

    • You just have to same command to mount the encrypted folder (i.e. Dropbox/Private) to the Private folder and you will be able to access your decrypted files. Similarly, any file you place in the Private folder will be encrypted and save in the Dropbox/Private folder.

      • Sorry, I must be missing something here. I’ve got the encrypted folder mounted (it’s called OSXFUSE Volume 1 (encfs), and when I save my file in Dropbox from the web to this folder, it’s still encrypted. The name is encrypted and so are the contents. All I get is a file called keUcn4VKD6PfQRMXy1f9a7oO – which quite clearly is encrypted, so much so, even I can’t read it

        • When you say “it’s still encrypted“, do you mean that you place the encrypted files in this mounted folder? If yes, then you are doing it wrongly. You need to place the encrypted files in the “Dropbox/Private” folder. When you mount this folder to the Private folder, the files will be decrypted all by itself.

  2. # does anybody know, how to correct this?
    $ encfs ~/Dropbox/Private ~/Private
    dyld: lazy symbol binding failed: Symbol not found: __ZN5boost7archive17xml_iarchive_implINS0_12xml_iarchiveEEC2ERSij
    Referenced from: /usr/local/Cellar/encfsmacosxfuse/1.7.4p2/lib/libencfs.6.dylib
    Expected in: flat namespace

    dyld: Symbol not found: __ZN5boost7archive17xml_iarchive_implINS0_12xml_iarchiveEEC2ERSij
    Referenced from: /usr/local/Cellar/encfsmacosxfuse/1.7.4p2/lib/libencfs.6.dylib
    Expected in: flat namespace

    Trace/BPT trap: 5

  3. The “~” in the command line is a shortcut to the home directory. You may want to use the full path instead, like:

    $ encfs /home/damien/Dropbox/Private /home/damien/Private

  4. I’m also a happy Dropbox and EncFS user, but I always wanted to have the sync status icons in Finder for my encrypted files.
    Therefore, I wrote a little Mac Tool that brings the Finder overlays to EncFS/Boxcryptor Classic volumes.
    So this could be helpful for some of you, too. Check it out at:
    http://mkieselmann.de/pebblestatus

    And its free ;-)

  5. On OXS 10.9.1 I got the encfslogin.sh script working after changing the last line to:
    security find-generic-password -ga encfs -w | “$ENCFS” -S “$ENCDIR” “$DECDIR”

  6. For anyone looking to use this configuration in a serious way, i thought i’d share my experiences. We decided to setup pretty much the same system almost 3 years ago now, to use in a commercial setting to share documents between multiple computers and people at work. A total 10 users, with over 10GB of word, excel, powerpoint, pdf, etc files.

    First of all this tutorial is excellent, we’ve been doing something similar from snow-lepoard, to lion, and mountain lion now (we haven’t migrated any further yet). At start we were using MacFUSE which has now been replaced for FUSE for OSX as the tutorial explains.

    Overall the experiences has been very positive, and we’re still using it. It’s a free solution which works pretty well. There’s a couple of little strangenesses which you get use to after a while. Most notable is that because of the way Microsoft Office works, it creates hidden files to keep lock state of open files, this get a bit confused with EncFS, so from time to time a file has been closed by everyone, but if you then open it, say Excel still believes the file is open by someone else and only gives you the file read-only. It happens sometimes, very easy to fix though, you just have to delete the little hidden file (which we have a script for now). Other niggle is that in the latest versions of Mac OS X it has features to auto-write and recover text files, images and so on. So basically when you edit a file it automatically saves it, but you have recovery options. This only works with a Mac filesystem, on not with the EncFS drive. So as well as losing this feature a lot of applications, such as TextEditor, or Preview, will complain that they can’t auto-write and recover. Final thing is, as far as I know, if you delete a file inside the EncFS drive, that’s it deleted, there’s no moving to Trash and recovery, if you delete it’s over, so you have to be a bit careful.

    All and all, I would recommend the setup Damien has explained here, and its a really good tutorial. Bear in mind that if you have a working setup, and update Mac OS X, there’s a chance it will stop working or you may have to re-install or update some of the tools in the chain (EncFS, Fuse for OSX and so on)

Comments are closed.

Sponsored Stories