EcryptFS
Unter Ubuntu wird damit (auf Wunsch) das Homeverzeichnis verschlüsselt.
sudo apt-get install ecryptfs-utils
Nutzung: http://wiki.ubuntuusers.de/ecryptfs/Nutzung
Auch interessant: Verschlüsselte Backups über das Internet
~/Private
entsperren:
ecryptfs-mount-private
Wieder sperren:
ecryptfs-umount-private
~/.ecryptfs/auto-mount ~/.Private - underlying directory containing encrypted data ~/Private - mountpoint containing decrypted data (when mounted) ~/.ecryptfs/Private.sig - file containing signature of mountpoint passphrase ~/.ecryptfs/Private.mnt - file containing path of the private directory mountpoint ~/.ecryptfs/wrapped-passphrase - file containing the mount passphrase, wrapped with the login passphrase ~/.ecryptfs/wrapped-independent - this file exists if the wrapping passphrase is independent from login passphrase
Quelle1)
In the event that you did not write down your mount passphrase, you may be able to recover it by decrypting the file /home/username/.ecryptfs/wrapped-passphrase using your login passphrase.
If your login passphrase matches the passphrase used to encrypt the wrapped-passphrase file, your mount passphrase will be written to screen. Record and protect this data accordingly.
If you have lost your wrapped-passphrase file, and you did not record your mount passphrase, it is impossible to access your encrypted data.
Quelle2)
There are two methods of using the live cd to open a encrypted home directory. The first will be the long way. The long way gives you more functionality in your home directory. It is also easier to do. The second will be the short way. The second way requires you to know about your system and how you partitioned it. It is more difficult to get more functionality, but is still possible. I prefer the long way.
The first thing you need to do is mount your linux partitions. Please use nautilus to do this. The guide will make a lot more sense if you do this. Nautilus is the default file manager of gnome. If you are using a kde or xfce live cd the syntax may be different below so please install nautilus if that is the case with this command.
~ $ sudo apt-get install nautilus
If you are confident in your ability to use the mount the command then you can use that, but you will have to manipulate the directory information below for it to work properly. Use this command to to find your Linux partitions.
~ $ sudo fdisk -l
My output
~ $ sudo fdisk -l Disk /dev/sda: 100.0 GB, 100030242816 bytes 255 heads, 63 sectors/track, 12161 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c8b89 Device Boot Start End Blocks Id System /dev/sda1 1 1245 9999360 83 Linux /dev/sda2 1246 5478 33998849 5 Extended /dev/sda3 * 5479 12161 53681197+ 7 HPFS/NTFS /dev/sda5 1246 1743 3998720 82 Linux swap / Solaris /dev/sda6 1744 5478 29999104 83 Linux
In this case you would have to to mount /dev/sda1 and /dev/sda6. I am going to assume you know how to do this if you want to manually mount your partitions.
Next you need find your „.Private“ directory. It is possible to have a „.Private“ symlink. So be careful. Use this command to find it.
~ $ sudo find / -type d -iname '.Private' 2>/dev/null
You should get something similar to this:
~ $ /media/<disk>/.ecryptfs/<user>/.Private ~ $ /media/<disk>/<user>/.Private
In my case I got the first one.
~ $ sudo find / -type d -iname '.Private' 2>/dev/null /media/4fa4e92e-3532-48fd-a83d-6ea340a669b6/.ecryptfs/bob/.Private
Next you need to find your keyring keys. This requires that you have your mount passphrase. You recorded when you setup the mount–this passphrase is different from your login passphrase. If you don't have your mount passphrase please read here (Recovering Your Mount Passphrase). Lets move on to getting those keyring keys. Put the sudo command into the terminal that you see below. This will be a interactive prompt. The left side of what you see is what you will see and the right side will give you more information. The second keyring in the square brackets is the important part.
Next you need to mount the appropriate „.Private“ directory. That you found earlier. You also need to understand the mount syntax to mount everything correctly.
sudo mount -t ecryptfs sdtm ldm
I recommend mounting at /home/username. Replace username with whatever username you want to use. I will be mounting at /home/bob. Since this is a live cd the directory will not exist, so you need to create it. Use this command to create your directory.
sudo mkdir /home/username
After you have created the directory that you want to mount at, please use this command that I showed you above.
sudo mount -t ecryptfs sdtm ldm
An example of putting all of this together would be:
sudo mount -t ecryptfs /media/4fa4e92e-3532-48fd-a83d-6ea340a669b6/.ecryptfs/bob/.Private /home/bob
Next you will have a interactive prompt.
If everything worked out correctly you should be able to see everything in /home/username. My files will be in /home/bob.
There are several possible things that can go wrong. I will cover them here.
Error mounting eCryptfs: [-2] No such file or directory
Check your system logs; visit <http://launchpad.net/ecryptfs>
This is a common error that you get if you use a invalid directory when you give the mount command.
It is possible to get the message Mounted eCryptfs and still not be able to see your data. This most likely means that you did not mount „.Private“ directory. It is also possible that you mounted the wrong directory. This happened to me and was quite difficult to figure out. Thanks to this question on launchpad I was able to figure it out.
https://answers.launchpad.net/ecryptfs/+question/114209
Please check eCryptfs for any other problems.
As I said this method is more difficult. If your home directory is installed on your / root partition it makes life easier. If you have a /home partition then you need to find both your /home partition and / root partition. Use nautilus to mount your linux partitions. Then use these two commands so you can figure out if you have a /home partition or not.
~ $ sudo fdisk -l ~ $ df -h
Note: The linux partitions must be mounted or you will not be able to get the information you need.
Here is my output.
~ $ sudo fdisk -l
Disk /dev/sda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c8b89
Device Boot Start End Blocks Id System
/dev/sda1 1 1245 9999360 83 Linux
/dev/sda2 1246 5478 33998849 5 Extended
/dev/sda3 * 5479 12161 53681197+ 7 HPFS/NTFS
/dev/sda5 1246 1743 3998720 82 Linux swap / Solaris
/dev/sda6 1744 5478 29999104 83 Linux
~ $ df -h
Filesystem Size Used Avail Use% Mounted on
aufs 1.6G 1.5G 103M 94% /
none 1.6G 280K 1.6G 1% /dev
/dev/sr0 700M 700M 0 100% /cdrom
/dev/loop0 682M 682M 0 100% /rofs
none 1.6G 5.3M 1.6G 1% /dev/shm
tmpfs 1.6G 34M 1.6G 3% /tmp
none 1.6G 92K 1.6G 1% /var/run
none 1.6G 0 1.6G 0% /var/lock
/dev/sda3 52G 32G 21G 61% /media/D07C698F7C697160
/dev/sda6 29G 9.4G 18G 35% /media/4fa4e92e-3532-48fd-a83d-6ea340a669b6
/dev/sda1 9.4G 4.2G 4.9G 47% /media/4fb33fae-d738-405d-8ba1-bc1ede832411
In my case I have a /home partition and / root partition. I can tell this by looking at /dev/sda1 and /dev/sda6. If you look at the sudo fdisk -l you can see /dev/sda1 and /dev/sda6 are my linux partitions. If you look at the df -h I can see /dev/sda6 is much bigger than /dev/sda1 so I know /dev/sda6 is my /home partition.
If you have a home directory and / root partition do this. http://blog.dustinkirkland.com/2009/03/mounting-your-encrypted-home-from.html
ubuntu@ubuntu$ sudo mount /dev/sda1 /mnt
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
root@ubuntu$ su - kirkland
kirkland@ubuntu$ ecryptfs-mount-private
Enter your login passphrase:
Warning: Using default salt value (undefined in ~/.ecryptfsrc)
Inserted auth tok with sig [xxx] into the user session keyring
kirkland@ubuntu$ cd $HOME
kirkland@ubuntu$ ls -alF
...
kirkland@ubuntu$ cat .profile
Here is an example of putting this into action. I attached the thread decribes what is going on. http://ubuntuforums.org/showthread.php?t=1643532
# Set up chroot : # Note my install (both home and /) on sda3 ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt 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 # As you say, there is no "bodhi" on the live CD: ubuntu@ubuntu:~$ id bodhi id: bodhi: No such user # But after we chroot ... ubuntu@ubuntu:~$ sudo chroot /mnt root@ubuntu:/# id bodhi uid=1000(bodhi) gid=1000(bodhi) groups=1000(bodhi),4(adm),20(dialout),24(cdrom),46 (plugdev),111(lpadmin),119(admin),122(sambashare) # su to bodhi root@ubuntu:/# su - bodhi keyctl_search: Required key not available Perhaps try the interactive 'ecryptfs-mount-private' To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. # But home is encrypted ... bodhi@ubuntu:~$ ls Access-Your-Private-Data.desktop README.txt # Decrypt home bodhi@ubuntu:~$ ecryptfs-mount-private Enter your login passphrase: Inserted auth tok with sig [b0d08471978769db] into the user session keyring INFO: Your private directory has been mounted. INFO: To see this change in your current shell: cd /home/bodhi # We will not see the data until we cd into the decrypted home # read the README.txt =) bodhi@ubuntu:~$ ls Access-Your-Private-Data.desktop README.txt # so cd ... bodhi@ubuntu:~$ cd # Now we can see the decrypted data ... bodhi@ubuntu:~$ ls bin Desktop Downloads Music Public Videos bzr Documents examples.desktop Pictures Templates zen
We can access the data, as root, from the live CD (gksu nautilus) at /mnt/home/bodhi
If you have a /home partition and / root partition do this. I will now assume you know where /home partition and / root partition. Mount your /root partition like this. Replace the appropriate number for where your /root partition is.
sudo mount /dev/sda1 /mnt
Mount your /home partition like this. Replace the appropriate number for where your /home partition is.
sudo mount /dev/sda6 /mnt/home
After that setup you chroot.
sudo mount -o bind /dev /mnt/dev sudo mount -o bind /dev/shm/ /mnt/dev/shm sudo mount -o bind /proc /mnt/proc sudo mount -o bind /sys /mnt/sys
Then chroot
sudo chroot /mnt /bin/bash
su to your username. My username is bob so I will use bob.
su - bob
Then decrypt home.
ecryptfs-mount-private
An example of this.
mint@mint ~ $ ls /media/4fa4e92e-3532-48fd-a83d-6ea340a669b6
bob joe lost+found Recycled RECYCLER
mint@mint ~ $ ls /media/4fb33fae-d738-405d-8ba1-bc1ede832411
bin home media opt root sys vmlinuz
boot initrd.img mnt proc sbin tmp
dev lib OldHome Recycled selinux usr
etc lost+found OldPrivate RECYCLER srv var
mint@mint ~ $ umount /media/4fa4e92e-3532-48fd-a83d-6ea340a669b6
mint@mint ~ $ umount /media/4fb33fae-d738-405d-8ba1-bc1ede832411
mint@mint ~ $ sudo mount /dev/sda1 /mnt
mint@mint ~ $ sudo mount /dev/sda6 /mnt/home
mint@mint ~ $ sudo mount -o bind /dev /mnt/dev
mint@mint ~ $ sudo mount -o bind /dev/shm/ /mnt/dev/shm
mint@mint ~ $ sudo mount -o bind /proc /mnt/proc
mint@mint ~ $ sudo mount -o bind /sys /mnt/sys
mint@mint ~ $ sudo chroot /mnt /bin/bash
_______________________________________
( Many changes of mind and mood; do not )
( hesitate too long. )
---------------------------------------
o
o
___
{~._.~}
( Y )
()~*~()
(_)-(_)
mint / # su - u bob
Unknown id: u
mint / # su - bob
keyctl_search: Required key not available
Perhaps try the interactive 'ecryptfs-mount-private'
_________________________________________
( "I don't think you have to go through )
( the process of reconfiguring X as I did )
( - that was partly because the )
( frustration made me brain dead." )
( )
( Husse Apr 5 2007 )
-----------------------------------------
o
o
___
{~._.~}
( Y )
()~*~()
(_)-(_)
bob@mint ~ $ ecryptfs-mount-private
Enter your login passphrase:
Error: Unwrapping passphrase and inserting into the user session keyring failed [-5]
Info: Check the system log for more information from libecryptfs
ERROR: Your passphrase is incorrect
Enter your login passphrase:
Error: Unwrapping passphrase and inserting into the user session keyring failed [-5]
Info: Check the system log for more information from libecryptfs
ERROR: Your passphrase is incorrect
Enter your login passphrase:
Inserted auth tok with sig [3bacfa4dde6b90dd] into the user session keyring
INFO: Your private directory has been mounted.
INFO: To see this change in your current shell:
cd /home/bob
bob@mint ~ $ ls -alF
total 32
drwx------ 5 bob bob 4096 2010-09-03 16:18 ./
drwxr-xr-x 8 root root 4096 2010-08-21 18:16 ../
lrwxrwxrwx 1 bob bob 56 2010-05-24 01:55 Access-Your-Private-Data.desktop -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
-rw------- 1 bob bob 214 2010-09-03 16:18 .bash_history
drwx------ 3 bob bob 4096 2010-07-15 23:29 .cache/
lrwxrwxrwx 1 bob bob 29 2010-05-24 01:55 .ecryptfs -> /home/.ecryptfs/bob/.ecryptfs/
-rw------- 1 bob bob 16 2010-09-03 16:18 .esd_auth
drwx------ 2 bob bob 4096 2010-11-12 15:00 .gconfd/
lrwxrwxrwx 1 bob bob 28 2010-05-24 01:55 .Private -> /home/.ecryptfs/bob/.Private/
drwx------ 2 bob bob 4096 2010-11-29 21:18 .pulse/
-rw------- 1 bob bob 256 2010-09-03 16:18 .pulse-cookie
lrwxrwxrwx 1 bob bob 52 2010-05-24 01:55 README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt
bob@mint ~ $ pwd
/home/bob
bob@mint ~ $ cd /home/bob
bob@mint ~ $ ls -alF
total 16672
drwx------ 92 bob bob 28672 2010-12-09 01:12 ./
drwxr-xr-x 8 root root 4096 2010-08-21 18:16 ../
-rw-r--r-- 1 bob bob 88038 2010-08-31 02:43 20 group list.txt
-rwxr-xr-x 1 bob bob 191 2010-10-28 15:34 .xprofile*
bob@mint ~ $ pwd
/home/bob
To access the data, do not exit the chroot. Open a new terminal and run nautilus as root.
gksu nautilus
You can not run graphical applications directly from the chroot, you would need to connect to the chroot via a VNC or ssh -X.
Perhaps an Encrypted Private Directory is not for you. To remove this setup:
$ ecryptfs-umount-private
$ chmod 700 ~/Private<
$ rm -rf ~/Private ~/.Private ~/.ecryptfs
$ sudo apt-get remove ecryptfs-utils libecryptfs0
A possible security problem that can crop up, is the event that the user logs in and then immediately leaves the computer physically usable to another person. The Private folder is unlocked as soon as the user logs in, the owner would not have had the chance to lock the folder, and the other person can take control of the computer and access it while the owner is away.
We can stop ecryptfs from unlocking the Private folder on startup, by removing the empty file auto-mount which is located in ~/.ecryptfs/, where you also can remove the auto-umount file, if you would like ecryptsfs to stop unmounting the private folder upon shutdown and logout.
For some reason the script fails to ask for a password, when you simply log out and in. You have to reboot the machine, or you will be able to just click on the mount script and the folder is mounted.
To resolve this problem, it is possible to have the script that unmounts the Private folder to run at login, so it cannot be accessed without the password being put in first. To do this:
This is a quick and dirty solution to this problem. If there's a better way, please replace this with it.