Encrypt Your Data With EncFS (OpenSUSE 12.3)

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Fri, 2013-04-12 16:36. :: SuSE | Security | Storage

Encrypt Your Data With EncFS (OpenSUSE 12.3)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter
Last edited 04/12/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 OpenSUSE 12.3 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 OpenSUSE 12.3 system in this tutorial.

 

2 Installing EncFS

Become root first:

su

EncFS can then be installed as follows:

zypper install 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@linux-ci7w:~> 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@linux-ci7w:~>

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@linux-ci7w:~> mount
devtmpfs on /dev type devtmpfs (rw,relatime,size=1020060k,nr_inodes=255015,mode=755)
tmpfs on /dev/shm type tmpfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sda2 on / type ext4 (rw,relatime,data=ordered)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/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)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
tmpfs on /var/lock type tmpfs (rw,nosuid,nodev,relatime,mode=755)
tmpfs on /var/run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,relatime)
tmpfs on /media type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda3 on /home type ext4 (rw,relatime,data=ordered)
none on /proc/fs/vmblock/mountPoint type vmblock (rw,relatime)
gvfs-fuse-daemon on /run/user/falko/gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)
encfs on /home/falko/decrypted type fuse.encfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=100,default_permissions)
falko@linux-ci7w:~>

and

df -h

falko@linux-ci7w:~> df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           12G  3.4G  7.5G  31% /
devtmpfs        997M  4.0K  997M   1% /dev
tmpfs          1004M   96K 1004M   1% /dev/shm
tmpfs          1004M  568K 1003M   1% /run
/dev/sda2        12G  3.4G  7.5G  31% /
tmpfs          1004M     0 1004M   0% /sys/fs/cgroup
tmpfs          1004M  568K 1003M   1% /var/lock
tmpfs          1004M  568K 1003M   1% /var/run
tmpfs          1004M     0 1004M   0% /media
/dev/sda3        17G  387M   16G   3% /home
encfs            17G  387M   16G   3% /home/falko/decrypted
falko@linux-ci7w:~>

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@linux-ci7w:~/decrypted> ls -l
total 8
-rw-r--r-- 1 falko users 10 Dec  5 20:04 bar
-rw-r--r-- 1 falko users 10 Dec  5 20:04 foo
lrwxrwxrwx 1 falko users  3 Dec  5 20:04 foo2 -> foo
falko@linux-ci7w:~/decrypted>

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

cd ~/encrypted
ls -l

falko@linux-ci7w:~/encrypted> ls -l
total 8
-rw-r--r-- 1 falko users 26 Dec  5 20:04 7ijqcKIYQH4hNiq1XjXYmozt
lrwxrwxrwx 1 falko users 24 Dec  5 20:04 eYgd4NX4d1bfjKPd61jmPZ5G -> 7ijqcKIYQH4hNiq1XjXYmozt
-rw-r--r-- 1 falko users 26 Dec  5 20:04 z8GFaXk7mXU7hgWxk0Md6zZn
falko@linux-ci7w:~/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@linux-ci7w:~> encfs ~/encrypted ~/decrypted
EncFS Password:
<-- yoursecretpassword
falko@linux-ci7w:~>

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@linux-ci7w:~> 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@linux-ci7w:~>

 

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.