Alex Scotton

App & Web Developer

Encrypted folders using EncFS (Ubuntu)

Posted by Alex Scotton on 26/6/2013

I've recently switched from DropBox to BitTorrent Sync, during the switch I decided to look into an easy way to encrpyt a few sensitive directories and discovered EncFS. It provides a command line interface for creating and mounting encrypted directories and was simple to setup:

1. Install EncFS

$ sudo aptitude install encfs

2. Create the Encrypted directory

Run the following command, answering y to questions regarding creating the directory:

$ encfs ~/.encrypted ~/visible

The setup will then request you specify an encryption level; paranoid mode utilises 256bit AES, however if you're familiar with encryption algorithms you may specify you're own encryption level, read more in the encfs docs.

3. Add files to your 'visible' directory

Add any files you wish to be encrypted to the newly created visible directory and use it as you would any normal directory.

4. Unmount

Once complete you can run the following command to unmount the visible directory, thus storing your files away within the .encrypted directory and leaving the visible directory empty:

$ fusermount -u ~/visible

Handy zsh alias

The mount and unmount commands aren't exactly handy, so add the following to your ~/.zshrc file for quick handy shortcuts:

enCrypt() {
    if [ ! $1 ] ; then
        print "Usage enCrypt [mount/unmount]"
        return 1
    elif [[ $1 = "mount" || $1 = "-m" ]] ; then
        print "Mounting encrypted store"
        encfs ~/.encrypted ~/visible
    elif [[ $1 = "unmount" || $1 = "-u" ]] ; then
        print "Unmounting encrypted store"
        fusermount -u ~/visible
    elif [ $1 ]; then
        print "Usage enCrypt [mount/unmount]"
        return 1
    fi
}

Then you can run:

$ enCrypt [mount/unmount]

To easily mount and unmount the encrypted drive