Encrypt Your Data With EncFS (Fedora 18)

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Wed, 2013-01-30 17:32. :: Fedora | Security

Encrypt Your Data With EncFS (Fedora 18)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter
Last edited 01/24/2013

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 Fedora 18 to encrypt your data.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I'm using the username falko on my Fedora 18 system in this tutorial.

 

2 Installing EncFS

Become root first:

su

EncFS can then be installed as follows:

yum install fuse-encfs

Exit the root shell:

exit

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:

[falko@localhost ~]$ 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 3:0:1
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:
 <-- yoursecretpassword
Verify Encfs Password: <-- yoursecretpassword
[falko@localhost ~]$

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

[falko@localhost ~]$ mount
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=498716k,nr_inodes=124679,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
/dev/mapper/fedora-root on / type ext4 (rw,relatime,data=ordered)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
tmpfs on /tmp type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw,relatime,data=ordered)
encfs on /home/falko/decrypted type fuse.encfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=100,default_permissions)
[falko@localhost ~]$

and

df -h

[falko@localhost ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
rootfs                    28G  1.4G   25G   6% /
devtmpfs                 488M     0  488M   0% /dev
tmpfs                    498M     0  498M   0% /dev/shm
tmpfs                    498M  1.2M  497M   1% /run
tmpfs                    498M     0  498M   0% /sys/fs/cgroup
/dev/mapper/fedora-root   28G  1.4G   25G   6% /
tmpfs                    498M  4.1M  494M   1% /tmp
/dev/sda1                485M   49M  411M  11% /boot
encfs                     28G  1.4G   25G   6% /home/falko/decrypted
[falko@localhost ~]$

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

[falko@localhost decrypted]$ ls -l
total 8
-rw-r--r-- 1 falko users 10 Jan 24 13:09 bar
-rw-r--r-- 1 falko users 10 Jan 24 13:09 foo
lrwxrwxrwx 1 falko users  3 Jan 24 13:09 foo2 -> foo
[falko@localhost decrypted]$

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

cd ~/encrypted
ls -l

[falko@localhost encrypted]$ ls -l
total 8
-rw-r--r-- 1 falko users 26 Jan 24 13:09 Ez7mif5fHHmDMRWaRouyGK76
-rw-r--r-- 1 falko users 26 Jan 24 13:09 gYyW44VYeupPQ2pGqZCQ,BT1
lrwxrwxrwx 1 falko users 24 Jan 24 13:09 zFtqX-gic8NNDHMm92dgQf8L -> Ez7mif5fHHmDMRWaRouyGK76
[falko@localhost encrypted]$

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:

[falko@localhost ~]$ encfs ~/encrypted ~/decrypted
EncFS Password:
<-- yoursecretpassword
[falko@localhost ~]$

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.

[falko@localhost ~]$ 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.
[falko@localhost ~]$

 

4 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by patrick (not registered) on Wed, 2013-02-27 17:58.
I have been using fedora for some time but was not aware of this user space encryption capability. It works very well and I am going to try to use dot directories next time. Only thing I did not see in this tutorial is how to remove the encryption password and the two directories, if someone needs to start over. thanks