I've done something a bit, well, strange. I installed Ubuntu 12.04 directly onto a USB thumb stick, encrypting the /home directory as given the option during the install. The filesystem is btrfs, I believe.
I've now stuck this into my computer running Ubuntu, and I'd like to copy a file onto the USB stick. How can I go about mounting the encrypted home directory so I can copy files to it?
You can use
ecryptfs-recover-private
.It will promt for the mount password, unlock the wrapped-passphrase and mount the directory in read only mode under
/tmp/
with just single command. Use the flag--rw
to mount the encrypted filesystem as read and write.You can check the man page for more information.
NB: This answer is correct, but another - newer and faster - way exists requiring only a single step with
ecryptfs-recover-private
. Make sure to check all answers below.To get access to the data on your stick and to copy files onto it you need to mount the eCryptfs. This involves several steps:
First you should insert your stick. If Ubuntu doesn't mount it automatically (It usually does.), you should mount it.
Now you should find a directory called
.Private
. If you did a default installation, this directory should sit in/media/DISK/home/.ecryptfs/USERNAME/.Private
. In this exampleDISK
is the directory where your stick is mounted andUSERNAME
is the name of the user you entered at installation. If you can't find it yourself open a terminal and enterI assume in the following steps that the directory is in
/media/DISK/home/.ecryptfs/USERNAME/.Private
.You need the mount password. This is different from your login pasword. Enter the following command into a terminal:
You have to enter the login password from the installation of your USB-Ubuntu (not your usual password). The command outputs a passphrase. Write this down or copy it into a file.
The password enables you to unlock the directory. You need to do it in two steps:
The first command adds your passphrase to the kernel keyring and the second tries to mount your
.Private
to the directory/media/myUSB
. If the latte doesn't exist, you have to create it first:The
mount
command will ask again for the login password. Next it will ask for a bunch of stuff.aes
and16
).n
for plaintext passthrough.y
for filename encryption.ecryptfs-add-passphrase --fnek
command you just typed. There are two lines starting withInserted auth tok …
. Insert the value in square brackets of the second output (123456789abcdef0
).Now you can access the files in
/media/myUSB
and can copy from and to the directory or subdirectories.A large part of my description is from "Live CD method of opening a encrypted home directory".
I had similar problem and ended here. I was migrating my system to another hard drive and have the same user with encrypted home on both old and new system.
I tried
but that directory was in fact symbolic link to
The target directory existed, but pointed to .Private on my new disk.
Correct command should be:
maybe ecryptfs-recover-private should display warning if it detects this pattern. It looks like common mistake.
The passphrase unwrap did not work. I needed to execute: