HPR1101: Recovery of an (en)crypted home directory in a buntu based system




Hacker Public Radio show

Summary: Recovery of an (en)crypted home directory in a 'buntu based system by 5150 This is going to be the archetypal “How I Did It” episode because if fulfills the criterion of dealing with an issue most listeners will most likely never have to resolve, but might be invaluable to those few who some day encounter the same problem, how to recover an encrypted home folder on an Ubuntu system. I enabled home folder encryption on installation of a Linux Mint 8 system some years back and it never gave me trouble until the day that it did. Suddenly, my login would be accepted, but then I would come right back to GDM. Finally I dropped into a text console to try to recover the contents of my home folder, and instead found two files, Access-Your-Private-Data.desktop and README.txt . README.txt explained that I had arrived in my current predicament because my user login and password for some reason were no longer decrypting my home folder (Ubuntu home folder encryption is tied to your login, no additional password is required). Honestly, until I lost access to my files, I 'd forgotten that I'd opted for encryption. I found two articles that described similar methods of recovery. I'd tried that following their instructions and failed, probably because I was mixing and matching what seemed to be the easiest steps to implement from the two articles. When I took another look at the material weeks later, I discovered I missed a link in the comments that led me to an improved method added at Ubuntu 11.04 that saves several steps: http://blog.dustinkirkland.com/2011/04/introducing-ecryptfs-recover-private.html Boot to an Ubuntu distribution CD (11.04 or later) Create a mount point and mount the hard drive. Of course, if you configured you drive(s) with multiple data partitions (root, /home, etc) you would have to mount each separately to recover all the contents of your drive, but you only have to worry about decrypting your home directory. If you use LVM, and your home directory spans several physical drives or logical partitions, I suspect things could get interesting. $sudo mkdir /media/myhd /media is owned by root, so modifying it requires elevation You need to confirm how your hardrive is registered with the OS. I just ran Disk Utility and confirmed that my hard drive was parked at /dev/sda, that meant that my single data partition would be at /dev/sda1 $sudo mount /dev/sda1 /media/myhd Do a list on /media/myhd to confirm the drive is mounted $ls /media/myhd The new recovery command eliminates the need to re-create your old user $sudo ecryptfs-recover-private (yes, ecrypt not encrypt) You will have to wait a few minutes while the OS searches your hard drive for encrypted folders When a folder is found, you will see INFO: Found [/media/myhd/home/.ecryptfs/username/.Private]. Try to recover this directory? [Y/n] Respond “Y” You will be prompted for you old password You should see a message saying your data was mounted read only at /tmp/ecryptfs.{SomeStringOfCharacters} I missed the mount point at first, I was look for my files in /media/myhd/home/myusername If you try to list the files in /tmp/ecryptfs.{SomeStringOfCharacters}, you will get a “Permission Denied” error. This because your old user owns these files, not your distribution CD login [You will probably want to copy “/tmp/ecryptfs.{SomeStringOfCharacters}” into your terminal buffer as you will need to reference it in commands. You can select if with your mous