Comment 2 for bug 1195399

Revision history for this message
TJ (tj) wrote :

If you wish to test this script here's the procedure.

1. Download and install
2. Give execute permissions
3. Create a test user account
4. Log-in as the test user
5. Run the script
6. Log-out/in/out as test user
7. Delete the test user account

# Download and install
$ wget -O - https://bugs.launchpad.net/ubuntu/+source/ecryptfs-utils/+bug/1195399/+attachment/3716219/+files/ecryptfs-unencrypt-home | sudo dd of=/usr/local/bin

# Give execute permissions
$ sudo chmod a+x /usr/local/bin/ecryptfs-unencrypt-home

# Create a test user account
$ sudo adduser --encrypt-home test_e

# Log-in as the test user
$ su -l test_e

test_e@ubuntu:~$

# Run the script. It will check whether /home/ is on a separate file-system
test_e@ubunut:~$ ecryptfs-unencrypt-home
Found a separate /home/ file-system
[sudo] password for test_e:
Some commands in this script (mount) will request 'sudo' privileges.
Sorry, user test_e may not run sudo. Please use an account with privileges to run the following commands and then re-run this script:
sudo mkdir -p /tmp/mnt/home
sudo mount /dev/mapper/Ubuntu-Home /tmp/mnt/home

# At this point the script has determined that the user doesn't have mount permissions and requires another user account to perform these steps. At another terminal using a sudo-privileged account follow the instructions:

$ sudo mkdir -p /tmp/mnt/home
$ sudo mount /dev/mapper/Ubuntu-Home /tmp/mnt/home

# And now, at the test_e session, re-run the script. It will check the mount has been performed before continuing:

test_e@ubuntu:~$ ecryptfs-unencrypt-home
Found a separate /home/ file-system
[sudo] password for test_e:

Contents of the new, unencrypted home, are currently:
total 8
dr-x------ 2 test_e test_e 4096 Jun 27 18:33 .
drwxr-xr-x 8 root root 4096 Jun 27 18:33 ..
lrwxrwxrwx 1 test_e test_e 56 Jun 27 18:33 Access-Your-Private-Data.desktop -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
lrwxrwxrwx 1 test_e test_e 32 Jun 27 18:33 .ecryptfs -> /home/.ecryptfs/test_e/.ecryptfs
lrwxrwxrwx 1 test_e test_e 31 Jun 27 18:33 .Private -> /home/.ecryptfs/test_e/.Private
lrwxrwxrwx 1 test_e test_e 52 Jun 27 18:33 README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt

Copying encrypted home files to unencrypted location, this may take some time...
sending incremental file list
./
.bash_logout
.bashrc
.profile
examples.desktop

sent 13859 bytes received 91 bytes 27900.00 bytes/sec
total size is 13537 speedup is 0.97

Switching to the unencrypted home...

INFO: Your private directory has been unmounted.
INFO: To see this change in your current shell:
  cd /home/test_e

...done.

Moving but preserving the .ecryptfs links (in case you want to reverse the process)
ecryptfs links are now in /home/test_e/.ecryptfs-home/

Your unencrypted files have not been deleted from /home/.ecryptfs/test_e
If you really want to delete them (and the .ecryptfs links) re-run this script with:
ecryptfs-unencrypt-home --really-delete-encrypted-files

Sorry, user test_e may not run sudo. Please use an account with privileges to run the following commands:
sudo umount /tmp/mnt/home
sudo rmdir /tmp/mnt/home
sudo rmdir /tmp/mnt
Finished.

# Log-out from the test_e session:
test_e@ubuntu:~$ exit

# With sudo privileges, execute the instructions
$ sudo umount /tmp/mnt/home
$ sudo rmdir /tmp/mnt/home
$ sudo rmdir /tmp/mnt

# Try logging in again
$ su -l test_e

# check files
test_e@ubuntu:~$ ls -al
total 40
drwx------ 3 test_e test_e 4096 Jun 27 18:41 .
drwxr-xr-x 8 root root 4096 Jun 27 18:33 ..
-rw------- 1 test_e test_e 29 Jun 27 18:41 .bash_history
-rw-r--r-- 1 test_e test_e 220 Jun 27 18:33 .bash_logout
-rw-r--r-- 1 test_e test_e 3637 Jun 27 18:33 .bashrc
drwxrwxr-x 2 test_e test_e 4096 Jun 27 18:38 .ecryptfs-home
-rw-r--r-- 1 test_e test_e 8942 Jun 27 18:33 examples.desktop
-rw-r--r-- 1 test_e test_e 675 Jun 27 18:33 .profile

# If you wish to permanently delete the encrypted files then re-run the script as it suggested:
test_e@ubuntu:~$ ecryptfs-unencrypt-home --really-delete-encrypted-files
Deleting encrypted files
rm -rf /home/.ecryptfs/test_e
rm -rf /home/test_e/.ecryptfs-home
Done.
No .ecryptfs files or links remain.

# Log-out
test_e@ubuntu:~$ exit

# Remove the test account
$ sudo deluser --remove-home test_e