Encrypted Online Storage

This is a quick tutorial on using EncFS over SSHFS in order to provide an encrypted online storage solution.

It assumes that you currently have a valid SSH login to an online server and you are using Ubuntu 7.10 . It should work in other Ubuntu versions or Debian and Debian-derived distributions, but I will not make any guarantees. If you are using an older version, you will need to upgrade both EncFS and SSHFS to newer versions. Ubuntu 7.10 comes with EncFS 1.3.2 and SSHFS 1.7.2 .

Firstly, we need to install both EncFS and SSHFS.

sudo apt-get install encfs sshfs

Once installed, we need to create several mountpoints, preferably in your home folder.

mkdir ~/.sshfsmt
mkdir ~/encrypted

~/.sshfsmt will be mountpoint of the SSH server and where the encrypted files will be stored in. ~/encrypted will be the mountpoint for the unencrypted files.

Before proceeding any further, we need to ensure that you belong to the fuse group, or otherwise you will not be able to mount the file systems.

sudo adduser $USERNAME fuse

Now, we need to mount the SSH server onto the SSHFS mountpoint, but due to a quirk of SSHFS, we need to manually specify the user and group for the mounting operation to ensure that you will be able to access it properly when EncFS mounts.

Firstly, find your uid and gid by typing the following command.

id

Note your uid and gid for use in mounting SSHFS. You should also notice that you belong to the fuse group.

sshfs SSH_USERNAME@SSH_SERVER: ~/.sshfsmt -o uid=YOUR_ACTUAL_UID -o gid=YOUR_ACTUAL_GID

Once mounted, we now mount it into EncFS.

encfs ~/.sshfsmt ~/encrypted

The first time it mounts, it will ask you to set some encryption settings. That's it! Any file you store in ~/encrypted will be encrypted and uploaded to your SSH server and any file read will be downloaded and decrypted on the fly.

In ~/.sshfsmt, you will see files with encrypted file names and contents. These are the actual files stored on your SSH server and do not attempt to edit or write to them directly. Only access your files in ~/encrypted.

When you shut your computer down, the file systems will automatically be unmounted. To unmount them manually, use the following commands in the specified order.

fusermount -u ~/encrypted
fusermount -u ~/.sshfsmt

I hope you have found this quick-and-dirty tutorial useful for your needs.