Saturday, September 21, 2013

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.

Installing 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:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
This will install Homebrew in your system. If you have already installed Homebrew, you can ignore this step.
2. Go to the Fuse for OS X site and download the osxfuse.dmg file. Install osxfuse in your system.
3. Next, download the encfs.macosx package file to your Desktop and extract it.
In the terminal, “cd” to the encfs.macosx folder and execute the installer script.
cd ~/Desktop/encfs.macosx-master
./install.sh
This script will download the encfs copy from the web, install it with Homebrew and patch it to make it compatible with osxfuse.
Once the installation is completed, you will have encfs running in your system.

Using encfs in Mac OS X

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

 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.

Automount encrypted directory on startup

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.
#!/bin/bash
 
ENCFS="/usr/local/bin/encfs" 
ENCDIR="$HOME/Dropbox/Private"
DECDIR="$HOME/Private"
 
security find-generic-password -ga encfs 2>&1 >/dev/null | cut -d'"' -f2 | "$ENCFS" -S "$ENCDIR" "$DECDIR"
Save the file as “encfslogin.sh” in your User directory.
Make the script executable:
chmod a+x encfslogin.sh
3. Next, open AppleScript editor and paste the line:
do shell script "$HOME/encfslogin.sh"
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.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.