Create Encrypted Directory in Ubuntu Jaunty (9.04)


Setup Your Encrypted Directory

Install ecryptfs-utils

1. $ sudo apt-get install ecryptfs-utils
2. Setup your private directory ecryptfs-setup-private
3. Enter your login password, and either choose a mount pass phrase or generate one.
4. Logout, and Log back in to establish the mount

Use Your Encrypted Directory

After logging back in, all content of any files or folders you write in ~/Private will be encrypted when written to the disk, in the hidden directory ~/.Private.

Storing Your Keys, Email and other Data in ~/Private

It can be a good idea to move the content of your .evolution/, .ssh/ and .gnupg/ in ~/Private and replacing them with a symlink.

1. Make sure that the application whose data you want to protect (e.g. Firefox or Evolution) is not running

ps -ef | grep evolution 


2.Move the application's data directory (e.g. ~/.mozilla or ~/.evolution) into your ~/Private directory


$ mv ~/.evolution ~/Private

3. Establish a symbolic link from the old location to new location


$ ln -s ~/Private/.evolution ~/.evolution

Using in conjunction with Auto-login

Automatic, password-less desktop logins will yield an un-mounted ~/Private directory. This is quite deliberately by design, ensuring that you must enter a password to access the encrypted data in the ~/Private directory.

If you use the ecryptfs-setup-private from ecryptfs-utils version 53-1ubuntu13 or beyond, if you open your ~/Private folder in Nautilus or Konqueror, you should see two files, README.txt, and "Access Your Private Data". If you click on "Access...", you will be prompted for your login password and your private data will be accessible.

If you created your ~/Private directory with an older version of ecryptfs-utils, you will need to manually establish a symlink for the "Access Your Private Data" icon. Here's how:

1. Update to the latest ecryptfs-utils package

$ sudo apt-get update && sudo apt-get upgrade
2.Ensure that ~/Private is not mounted


$ ecryptfs-umount-private

3. Establish the links in your unmounted ~/Private


$ cd ~/Private && sudo ln -sf /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt README.txt && sudo ln -sf /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop Access-Your-Private-Data.desktop
 
Recovering Your Data Manually

These steps should only be required in unusual, or emergency circumstances, when you must manually mount your encrypted ~/Private directory to recover your data. You can use this to mount your data if it's backed up on a different system, or using a LiveCD, as long as it is running at least the Linux 2.6.26 kernel.

1. Mount using sudo:


$ sudo mount -t ecryptfs /home/username/.Private /home/username/Private

Selection: 3 (use a passphrase key type)
Passphrase: (Enter the mount passphrase you recorded when you setup the mount--this passphrase is different from your login passphrase.) Selection: aes (use the aes cipher)
Selection: 16 (use a 16 byte key)
Enable plaintext passthrough: n

Assuming you entered your passphrase correctly, you should be able to temporarily access your data at /home/username/Private . Since you are using superuser privileges instead of your regular user account, you may get a warning that you might have entered the passphrase wrong, even if you didn't:

WARNING: Based on the contents of [/root/.ecryptfs/sig-cache.txt], it looks like you have never mounted with this key
before. This could mean that you have typed your
passphrase wrong.

It is safe to ignore this warning.
 

Recovering Your Mount Passphrase

In the event that you did not write down your mount passphrase, you may be able to recover it by decrypting the file ~/.ecryptfs/wrapped-passphrase using your login passphrase.
ecryptfs-unwrap-passphrase ~/.ecryptfs/wrapped-passphrase "login passphrase" It's a good idea to clear your shell history at this point to erase your login passphrase
 

$ history -c

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.

How to Remove an Encrypted Private Directory Setup

Perhaps an Encrypted Private Directory is not for you. To remove this setup:

1. Ensure that you have moved all relevant data out of your ~/Private directory
2. Unmount your encrypted private directory


$ ecryptfs-umount-private

3. Make ~/Private writable again


$ chmod 700 ~/Private

4.Remove ~/Private, ~/.Private, ~/.ecryptfs


$ rm -rf ~/Private ~/.Private ~/.ecryptfs

5. Uninstall the utilities


$ sudo apt-get remove ecryptfs-utils libecryptfs0

Sources :
https://help.ubuntu.com/

Happy Testing...!!!

1 comment:

  1. Thank you!! I googled around a while before I found this. No one else describes how to encrypt files this as well. Most of the other sites describe setting up an encrypted user. I upgraded to Jaunty and don't want to have to fiddle with recreating my user account. This works great!

    ReplyDelete

Please Comment...!!