There is a new revision of this tutorial available for Ubuntu 16.04 (Xenial Xerus).

Encrypt your data with EncFS on Ubuntu 15.10

EncFS provides an encrypted filesystem in user-space. It runs without any  special permissions and uses the FUSE library and Linux kernel module to provide the filesystem interface. It is a pass-through filesystem, not  an encrypted block device, which means it is created on top of an  existing filesystem. This tutorial shows how you can use EncFS on Ubuntu 15.10 (Wiley Werewolf) to encrypt your data.

 

1 Preliminary Note

I'm using the username falko on my Ubuntu 15.10 System in this tutorial. A security audit has revealed some issues in the current implementation of encfs, please see the security warning below to decide if the way that you want to use encfs is affected by these issues. An alternative to encfs is ecryptfs (https://launchpad.net/ecryptfs) that I will cover in another tutorial.

Encfs security information

"According to a security audit by Taylor Hornby (Defuse Security), the current implementation of Encfs is vulnerable or potentially vulnerable to multiple types of attacks. For example, an attacker with read/write access to encrypted data might lower the decryption complexity for subsequently encrypted data without this being noticed by a legitimate user, or might use timing analysis to deduce information. Until these issues are resolved, encfs should not be considered a safe home for sensitive data in scenarios where such attacks are possible."

 

2 Installing EncFS

EncFS can be installed as follows (we need root privileges, therefore we use sudo):

sudo apt-get install encfs

You should now take a look at the EncFS man page to familiarize yourself with its options:

man encfs

 

3 Using EncFS

I will now create the directories encrypted and decrypted in my home directory:

mkdir -p ~/encrypted
mkdir -p ~/decrypted

The decrypted directory acts as the mount point for the encrypted directory. To mount ~/encrypted to ~/decrypted, simply run:

encfs ~/encrypted ~/decrypted

If you run this command for the first time, the EncFS setup is started, and you must define a password for the encrypted volume:

[email protected]:~$ encfs ~/encrypted ~/decrypted
Creating new encrypted volume.
Please choose from one of the following options:
enter "x" for expert configuration mode,
enter "p" for pre-configured paranoia mode,
anything else, or an empty line will select standard mode.
?> <-- p

Paranoia configuration selected.

Configuration finished. The filesystem to be created has
the following properties:
Filesystem cipher: "ssl/aes", version 3:0:2
Filename encoding: "nameio/block", version 4:0:2
Key Size: 256 bits
Block Size: 1024 bytes, including 8 byte MAC header
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File data IV is chained to filename IV.
File holes passed through to ciphertext.

-------------------------- WARNING --------------------------
The external initialization-vector chaining option has been
enabled. This option disables the use of hard links on the
filesystem. Without hard links, some programs may not work.
The programs 'mutt' and 'procmail' are known to fail. For
more information, please see the encfs mailing list.
If you would like to choose another configuration setting,
please press CTRL-C now to abort and start over.

Now you will need to enter a password for your filesystem.
You will need to remember this password, as there is absolutely
no recovery mechanism. However, the password can be changed
later using encfsctl.

New Encfs Password: <-- Enter a secure password here
Verify Encfs Password: <-- Enter the secure password a second time

Make sure you remember the password because there's no way to recover your encrypted data if you forget the password!

You should now find the EncFS volume in the outputs of

mount

[email protected]:~$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=1006420k,nr_inodes=251605,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=204480k,mode=755)
/dev/mapper/server1--vg-root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,clone_children)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=21,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /boot type ext2 (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=204480k,mode=700,uid=1000,gid=1000)
encfs on /home/falko/decrypted type fuse.encfs (rw,nosuid,nodev,relatime,user_id=1001,group_id=1001)

and

df -h

[email protected]:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 983M 0 983M 0% /dev
tmpfs 200M 4.9M 195M 3% /run
/dev/dm-0 28G 1.7G 25G 7% /
tmpfs 999M 0 999M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 999M 0 999M 0% /sys/fs/cgroup
/dev/sda1 236M 51M 173M 23% /boot
tmpfs 200M 0 200M 0% /run/user/1000
encfs 28G 1.7G 25G 7% /home/falko/decrypted

To save your data in encrypted form, put your data into the decrypted directory, just as you would do with a normal directory:

cd ~/decrypted
echo "hello foo" > foo
echo "hello bar" > bar
ln -s foo foo2

If you check the contents of the directory, you will see that you can see it in unencrypted form...

ls -l

[email protected]:~/decrypted$ ls -l
total 8
-rw-rw-r-- 1 falko falko 10 Nov 10 14:57 bar
-rw-rw-r-- 1 falko falko 10 Nov 10 14:57 foo
lrwxrwxrwx 1 falko falko 3 Nov 10 14:57 foo2 -> foo

... while in the encrypted directory, it's encrypted:

cd ~/encrypted
ls -l

[email protected]:~/encrypted$ ls -l
total 8
lrwxrwxrwx 1 falko falko 24 Nov 10 14:57 gIKlbEtIpTfiGOCy,wKFpMFd -> nZgFI3s62v5LtaHOu-V4lUSy
-rw-rw-r-- 1 falko falko 26 Nov 10 14:57 mEqwt,ssEJhGYpN8HfJMoVxk
-rw-rw-r-- 1 falko falko 26 Nov 10 14:57 nZgFI3s62v5LtaHOu-V4lUSy

To unmount the encrypted volume, run:

cd
fusermount -u ~/decrypted

Check the outputs of...

mount

... and...

df -h

... and you will see that the EncFS volume isn't listed anymore.

To mount it again, run

encfs ~/encrypted ~/decrypted

You will be asked for the password you defined earlier:

[email protected]:~$ encfs ~/encrypted ~/decrypted
EncFS Password:
<-- yoursecretpassword

If you specify the correct password, this will mount the ~/encrypted directory to ~/decrypted from where you can access your encrypted data in unencrypted form. If you forget the password, your encrypted data is lost!

If you want to change the password, you can do this with the

encfsctl passwd ~/encrypted

command.

[email protected]:~$ encfsctl passwd ~/encrypted
Enter current Encfs password
EncFS Password:
<-- yoursecretpassword
Enter new Encfs password
New Encfs Password:
<-- newsecretpassword
Verify Encfs Password: <-- newsecretpassword
Volume Key successfully updated.

 

Share this page:

0 Comment(s)

Add comment