How can users protect themselves from the loss of important data when a computer goes missing? Well, the latest release of Ubuntu makes this not only possible, but frighteningly easy!
Recovery of an Encrypted Home Directory is possible from an Ubuntu 9.10 LiveCD.
Mount the disk partition containing the Encrypted Home Directory:
ubuntu@ubuntu$ sudo mount /dev/sda1 /mnt
Establish a proper chroot environment:
ubuntu@ubuntu$ sudo mount -o bind /dev /mnt/dev
ubuntu@ubuntu$ sudo mount -o bind /dev/shm /mnt/dev/shm
ubuntu@ubuntu$ sudo mount -o bind /proc /mnt/proc
ubuntu@ubuntu$ sudo mount -o bind /sys /mnt/sys
ubuntu@ubuntu$ sudo chroot /mnt
Become the user whose data needs recovery (i.e. “foo”) and manually add the necessary mount passphrase to the kernel session keyring:
root@ubuntu$ su – foo
foo@ubuntu$ ecryptfs-add-passphrase --fnek
Passphrase:
<Enter the recorded passphrase>
Mount the encrypted directory and then access the data:
foo@ubuntu$ ecryptfs-mount-private
foo@ubuntu$ cd $HOME
foo@ubuntu$ ls -alF
...
Anatomy of an Ubuntu Encrypted Home Directory
When a user is logged in and the Encrypted Home Directory is mounted, something like the following is in the kernel’s mount table:
/home/foo/.Private on /home/foo type ecryptfs
(ecryptfs_sig=009d8073058734f2, ecryptfs_fnek_sig=d27234f4a296af68, ecryptfs_cipher=aes, ecryptfs_key_bytes=16)
Listing the home directory and accessing files, the data appears in plain text:
foo@x200:~$ ls -alF $HOME
drwxr-xr-x 6 foo foo 4096 2009-06-06 16:19 ./
drwxr-xr-x 6 root root 4096 2009-06-06 13:21 ../
-rw------- 1 foo foo 5 2009-06-06 16:19 .bash_history
-rw-r--r-- 1 foo foo 220 2009-06-06 13:21 .bash_logout
-rw-r--r-- 1 foo foo 3115 2009-06-06 13:21 .bashrc
drwxr-xr-x 2 foo foo 4096 2009-06-06 16:19 .byobu/
drwx------ 2 foo foo 4096 2009-06-06 13:22 .ecryptfs/
-rw-r--r-- 1 foo foo 357 2009-06-06 13:21 examples.desktop
drwxr-xr-x 3 foo foo 4096 2009-06-06 16:19 Private/
drwxr-xr-x 3 foo foo 4096 2009-06-06 16:19 .Private/
-rw-r--r-- 1 foo foo 675 2009-06-06 13:21 .profile
-rw-r--r-- 1 foo foo 0 2009-06-06 16:19 .screenrc
However, when examining the underlying encrypted directory one can see that both the file names and contents are encrypted. Without access to the keys, this information should be inaccessible by an attacker:
foo@x200:~$ ls -alF /home/foo/.Private/
drwxr-xr-x 3 foo foo 4096 2009-06-06 16:19 ./
drwxr-xr-x 6 foo foo 4096 2009-06-06 16:19 ../
-rw------- 1 foo foo 12288 2009-06-06 16:19 ECRYPTFS_FNEK_ENCRYPTED.FWbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
0H9QfTTjNR-i4Dzfxeu20---
-rw-r--r-- 1 foo foo 12288 2009-06-06 16:19 ECRYPTFS_FNEK_ENCRYPTED.FWbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
-BZAi9gS3OOrhtsz4qdZwk--
-rw-r--r-- 1 foo foo 12288 2009-06-06 13:21 ECRYPTFS_FNEK_ENCRYPTED.FWbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
hojMJwfB7cxsUzym9ZXhK---
-rw-r--r-- 1 foo foo 12288 2009-06-06 13:21 ECRYPTFS_FNEK_ENCRYPTED.FWbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
lpAWuKSN-nfaJwnzwyGF4k--
drwxr-xr-x 2 foo foo 4096 2009-06-06 16:19 ECRYPTFS_FNEK_ENCRYPTED.FWbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
pDTNHxMN.eXLZF-7IO4mlU--
-rw-r--r-- 1 foo foo 12288 2009-06-06 13:21 ECRYPTFS_FNEK_ENCRYPTED.FWbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
sKm2CEPzbjUsOt9HE3ynTU--
-rw-r--r-- 1 foo foo 12288 2009-06-06 13:21 ECRYPTFS_FNEK_ENCRYPTED.FXbGQXHocdOjO-S70saK-StBFDWyUvngUSX8\
iiKk.q2g7bFIs2MaUaA8-LnJv7aptfhqA-ldgV9yHVI-
Both the mounted and unmounted home directory must contain a symbolic link to a non-encrypted eCryptfs configuration directory. The contents of this configuration directory usually looks like this:
foo@x200:~$ ls -alF .ecryptfs/
drwx------ 2 foo foo 4096 2009-06-06 13:22 ./
drwxr-xr-x 6 foo foo 4096 2009-06-06 16:19 ../
-rw-r--r-- 1 foo foo 0 2009-06-06 13:22 auto-mount
-rw-r--r-- 1 foo foo 0 2009-06-06 13:22 auto-umount
-rw------- 1 foo foo 18 2009-06-06 13:22 Private.mnt
-rw------- 1 foo foo 34 2009-06-06 13:22 Private.sig
-r-------- 1 foo foo 48 2009-06-06 13:22 wrapped-passphrase
The existence of the auto-mount and auto-umount flags inform PAM to automatically mount and unmount the eCryptfs directory. Private.mnt contains a path owned by the user where the eCryptfs directory is to be mounted, i.e, $HOME, $HOME/Private, or elsewhere. Private.sig contains signatures identifying the fekek and fnek, without revealing the keys themselves. Finally, the wrapped-passphrase contains the actual mount passphrase, symmetrically encrypted by the user’s system login passphrase.
Advanced Encrypted Home Directory Security
Some Ubuntu Encrypted Home Directory users choose to extend their security beyond the stock setup.
In the default Ubuntu Encrypted Home Directory model, the weakest link in the chain of required keys is usually the user’s system login password. While it is critically important to choose a strong system password, the risk can be mitigated by two-factor authentication.
Two-factor authentication is a system where two separate pieces of information are required to establish a user’s identity. It is trivial to simulate two-factor authentication with Ubuntu Encrypted Home Directories. Simply move $HOME/.ecryptfs/wrapped-passphrase to removable media (such as a USB key or flash disk) and establish a symbolic link from $HOME/.ecryptfs/wrapped-passphrase to the removable location. You can even obfuscate the name of the file on the removable media by calling it something other than “wrapped-passphraseâ€:
foo@x200:~$ ls -alF .ecryptfs/wrapped-passphrase
lrwxrwxrwx 1 foo foo 18 2009-06-06 16:41 .ecryptfs/wrapped-passphrase -> /media/disk/.garbage
By using this method, should an attacker manage to crack the log in password, they will not have access to the wrapped-passphrase, and therefore cannot decrypt the data. In order to gain access, they must brute-force a long, randomly generated passphrase before accessing the encrypted data.
Use of swap space and hibernation-to-disk present particularly difficult problems to encryption systems. Decrypted file contents exist exclusively as data structures in running memory. However, if memory gets swapped to disk and the swap space is not encrypted, some of the private data may be written in clear text. Indeed, if a system is hibernated, the complete contents of memory is dumped to disk, potentially circumventing the entire encryption scheme.
For these reasons, it is highly recommended that swap space is also encrypted when using Ubuntu Encrypted Home or Private Directories. The ecryptfs-setup-swap script should accomplish this nicely, however you will not be able to resume from hibernation (suspend/resume is unaffected). Thankfully, the Ubuntu 9.10 installer has already thought of this and will automatically encrypt swap space when enabling an Encrypted Home Directory.
Caveats
There are a few subtle changes to otherwise normal system operation with an Encrypted Home Directory.
If the home directory is not already mounted then automatic desktop logins, ssh public key authentication and cronjobs that require access to data in $HOME are not possible. This issue can be worked around by disabling automatic unmount (remove $HOME/.ecryptfs/auto-umount), logging in, and establishing the mount at some point prior to public key authentication or cronjob execution. However, the home directory will only be unmounted at shutdown, or when ecryptfs-umount-private is invoked directly.
eCryptfs does not yet work properly on top of remote, network file systems such as NFS, Samba, or SSHFS. This is a known bug and is actively being addressed.
Encrypted file contents are padded, requiring additional storage on disk. While this has little affect on large files, encrypted sparse files appear much bigger.
File and directory names are also padded. Linux has a 256-character file name limit, and a 4096-character maximum path limit. The padding from eCryptfs means that file names and paths which are already near the limit might hit the limit sooner than expected.
In Conclusion
Ubuntu has once again taken a complex, highly customizable free software system and made it seamlessly accessible to the wider population. By adding a suite of user space utilities, support in the Ubuntu installer and integration with system authentication, eCryptfs provides an elegant home directory encryption scheme while continuing to deliver an outstanding user experience.
Encrypted Home Directories proudly demonstrate Ubuntu’s leadership in developing a secure Linux desktop without sacrificing usability.
Dustin Kirkland is a Core Developer of the Ubuntu Server for Canonical, eCryptfs Upstream Maintainer, and founder of DivItUp.com
Comments on "Ubuntu’s Encrypted Home Directory: A Canonical Approach to Data Privacy"
Seems like a much better method than the encryption method used on my work laptop. After every reboot, I need to type in a password in addition to the login password.
If it’s using full-disk encryption, then you’re fine not using a login password. That way you still have to type your password in during a reboot, but only once, and that very quickly after boot.
Sounds like a wonderful idea for laptops that travel, but kind of a PITA, e.g., for a desktop at home that you like to access frequently via SSH because, as the article says,
\”if the home directory is not already mounted then automatic desktop logins, ssh public key authentication and cronjobs that require access to data in $HOME are not possible. This issue can be worked around by disabling automatic unmount (remove $HOME/.ecryptfs/auto-umount), logging in, and establishing the mount at some point prior to public key authentication or cronjob execution. However, the home directory will only be unmounted at shutdown, or when ecryptfs-umount-private is invoked directly.\”
I don\’t completely understand the workaround but, again, it sounds kind of painful.
Shouldn\’t be that difficult to combine with ssh remote logins if one uses the pam_mount module. I haven\’t used pam_mount with eCryptfs yet, but it should be possible according to
http://wiki.archlinux.org/index.php/System_Encryption_with_eCryptfs
Looks like a recipe for disaster. I have had a bad experience with encrypting a drive, the algorithm appeared to have a bug, it was encrypted allright, but impossible to recover. If you try this, you MAY want to take that backup of your unencrypted data you made and keep it in a safe somewhere. Encryption algorithms are complicated and sometimes fail. Bobby B.
Just how secure is Ubuntu\’s new encrypted home directory system, when it is installed using Ubuntu\’s default configuration ? Your article includes a nice explanation of how you can boot the PC using a Ubuntu LiveCD, and then recover the data.
Am I missing something here ? To me it looks like a \”bad guy\” who wanted to steal the confidential information stored on the notebook computer that he has just stolen could have access to your encrypted home partition data in a matter of minutes….
Your article suggests that you can make it harder for the bad guy by implementing two-factor authentication – \”simplymove $HOME/.ecryptfs/wrapped-passphrase to removable media (such as a USB key or flash disk)\”.
Yes this approach does put the wrapped passphrase on a USB Key or similar device, but all of these security measures are still reliant upon the thief not getting hold of the USB Key at the same time as the Notebook Computer is stolen. What are the odds that the User will end up storing the USB Key in the Laptop Bag, just so that they make sure that they always have the USB Key with them when they travel.
The concept of using the USB Key also raises a potential personal safety issue for the Computer User. If the thief has found a victim using a notebook computer, at say a coffee shop, the thief will also note that when the user shutdown the PC prior to leaving the Coffee Shop, that the user unplugged a USB Key and hung it around his neck or somewhere else on their person. Odds On – the thief, when he/she makes a move to distract you and steal your notebook computer, will also do a pick pocket job on your USB Key……
So – am I missing something ? Or does Ubuntu\’s new encrypted home directory functionality only protect your data against an honest thief, who knows nothing about Linux, and ideally who wouldn\’t also think to steal your USB Key at the same time they steal your Notebook computer ?????
To recover your data, you will require the encryption key which you were instructed to \”write down, print, etc and store in a *secure* location\”. So simply booting from a live CD doesn\’t give you anything more than access to the encrypted data (ie, useless).
Secondly, a lot of people store data on USB keys, when they shutdown, they remove the USB key and drop it in:
1) Laptop bag
2) Pocket
3) Keyring/etc/whatever
Unless you are being specifically targeted (ie, the thief knows where you work, and knows you have access to the data they are after) then they would only be interested in the re-sale value of the hardware. As such, the re-sale value of a USB key is negligible and so definitely not worth any additional risk.
The point of the above would be to ensure that the thief and/or recipient/purchaser of your laptop can\’t accidentally stumble across the fact that they have complete access to \”Some Corporate Server Farm\” or \”Some Users\” bank account details complete with passwords, or personal home movie collection, or whatever…
PS, the truly serious thief targeting the theft of a specific users laptop will go after the USB key, probably won\’t be concerned with threatening your safety, etc and if all else fails, will use automated decryption tools to access your decrypted data in 6 months or however long it would take. (BTW, anyone know how long it would take to brute force this type of encryption?)
PPS, This is definitely something I will be enabling on my laptops as soon as I install Ubuntu 9.10 which I am eagerly awaiting!
Regards,
Adam
http://www.websitemanagers.com.au
It is important to note that the mere presence of an encrypted volume or directory is enough of a reason (in and of itself) for your computer to be indefinitely seized in the US. Just so everyone is aware of this. \”Encryption\” _IS_ the probable cause in these instances.
@justwally: This is not true, either legally or in practice. Millions of individuals carry around encrypted folders, partitions and entire drives for many reasons. Anyone carrying HIPAA data, for example. It is not a basis for any search or seizure. Please do not spread disinformation on this point, as it has a chilling effect on the decision to encrypt.
@justwally: If we can advocate for encryption to become the default option in common operating systems (which I don\’t think is unreasonable in today\’s climate of data breeches and privacy concerns) encryption would no longer be grounds for probable cause.
I\’ve just tried the recovery, and the method described doesn\’t work. You need to create the directories in /mnt (that\’s not a problem).
But sudo chroot /mnt gives the error:
cannot run command \’/bin/bash\”: No such directory.
And su – foo (using the correct name for the user) also gives an error.
And ecrypt-mount-private says:
Encrypted private directory is not setup properly.
I have tried everything that I can think of, but to no avail. My /home is mounted on a separate directory, so I also have tried variations to cope with that, but it still doesn\’t work!
It seems impossible to find anywhere that documents how to recover an encrypted directory!
Mr pannsoln,
If you want to use a chroot, your should mount the root \”/\” inside your mount point. Since, from the jail, you wont see any directory from your $PATH… Thus you can\’t see /bin/bash either.
if you want to chroot inside /mnt, before do #: mount -o bind / /mnt
and create a mount point for any other mount that you want accessible from inside /mnt and mount them the same way.
The problem is not Ubuntu. It\’s just a little misunderstanding.
Regards,
BT
Thanks for this, very helpful! I believe there is a small error in the terminal commands. I think this line:
sudo ln -s /home/.ecryptfs/$USER/.ecryptfs /home/$USER.new/.ecryptfsShould actually read:
sudo ln -s /home/.ecryptfs/$USER /home/$USER.new/.ecryptfsHi! I realize this is kind of off-topic but I had to ask. Does managing a well-established website such as yours
require a lot of work? I’m completely new to writing a blog however I do write in my journal every day. I’d like to start
a blog so I will be able to share my own experience and thoughts online.
Please let me know if you have any suggestions or tips
for brand new aspiring blog owners. Appreciate
it!
Once the home directory is encrypted can I still run programs like sbackup to make unencrypted backups?
can I still run programs like sbackup
yep.
if you encrypt the home, and log in, it will be unencrypted to your eyes. you can do as you wish with the files.
i use a Private folder with manual mount so even logged in, my stuff is encrypted unless i change it.
when power is off your setup will protect your home folder from view, mine will only protect the Private folder. my only wish list contains multiple folders.