20

Few days back I have installed ecryptfs, created a private directory using it. Now my Ubuntu login became super slow. I have tried removing ecryptfs from Synaptic. I found It, it can not be deleted that way. Somewhere I have read about this command

ecryptfs-setup-private --undo

But this command displays a rather confusing list of commands on terminal. I don't want to mess up my installation, neither want to loose my administrator account.

Now my question is, how can I safely remove /home/user/Private (.Private) and remove ecryptfs encryption ?

1

3 Answers 3

20

The removal procedure is documented in the ecryptfs-setup-private(1) utility, with the --undo option:

$ ecryptfs-setup-private --undo

In the event that you want to remove your eCryptfs Private Directory setup,
you will need to very carefully perform the following actions manually:

 1. Obtain your Private directory mountpoint
   $ PRIVATE=`cat ~/.ecryptfs/Private.mnt 2>/dev/null || echo $HOME/Private`
 2. Ensure that you have moved all relevant data out of your $PRIVATE directory
 3. Unmount your encrypted private directory
   $ ecryptfs-umount-private
 4. Make your Private directory writable again
   $ chmod 700 $PRIVATE
 5. Remove $PRIVATE, ~/.Private, ~/.ecryptfs
    Note: THIS IS VERY PERMANENT, BE VERY CAREFUL
   $ rm -rf $PRIVATE ~/.Private ~/.ecryptfs
 6. Uninstall the utilities (this is specific to your Linux distribution)
   $ sudo apt-get remove ecryptfs-utils libecryptfs0

Full disclosure: I am one of the authors and maintainers of eCryptfs.

18
+50

Actually ecryptfs tells you very specifically what to do when you run ecryptfs-setup-private --undo, just follow its instructions.

Obtain your Private directory mountpoint

$ PRIVATE=`cat ~/.ecryptfs/Private.mnt 2>/dev/null || echo $HOME/Private`

This command populates the $PRIVATE variable with the path to your private directory. Either the path is stored in ~/.ecryptfs/Private.mnt file (where ~ is your home directory) or if the file doesn't exist, it will fall back to ~/Private path. You can then run echo $PRIVATE command to verify content of the PRIVATE variable. When you see $PRIVATE in the following commands, it will be substituted with the contents of the variable, ~/Private in your case.

Ensure that you have moved all relevant data out of your $PRIVATE directory

This is important.

Unmount your encrypted private directory

$ ecryptfs-umount-private

eCryptFS is kind of a filesystem which is mounted in user space (Wikipedia explains what's mounting about. That's also the reason why the Private folder cannot be removed so easily. Think of it as kind of proxy which transparently encrypts and decrypts your files. This command un-mounts the folder which effectively disables the encryption.

Make your Private directory writable again

$ chmod 700 $PRIVATE

chmod sets file permissions. In this case, you say: "make file/directory stored in $PRIVATE readable, writable and executable for me (700)" – you can't otherwise delete the directory since you don't have write access.

Remove $PRIVATE, ~/.Private, ~/.ecryptfs

Note: THIS IS VERY PERMANENT, BE VERY CAREFUL

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

This does exactly what it says. rm command means ReMove, -r means recursive (to recursively remove directories), and f means Force ("stop nagging me, just delete it"). This will remove all these three directories: $PRIVATE, ~/.Private, ~/.ecryptfs

If you want to, you can remove these directories manually from Nautilus (just check "View > Show hidden files" to see .Private and .ecryptfs directories in your home dir).

Uninstall the utilities (this is specific to your Linux distribution)

$ sudo apt-get remove ecryptfs-utils libecryptfs0

This will remove ecryptfs-utils and libecryptfs0. You can do this from Synaptic instead or just ignore it if you want to keep eCryptFS around (e.g. for other users).

If you follow these instructions, there's no risk of wrecking your system or losing your files – unless, of course, you don't backup your files from ~/Private directory.

8
  • 1
    Can you explain what this line means "$ PRIVATE=cat ~/.ecryptfs/Private.mnt 2>/dev/null || echo $HOME/Private" ? May 4, 2012 at 17:54
  • 1
    Dont just copy the commands from Terminal. Please post explanations of those commands,how I use them, what cautious measurements should I take etc. May 4, 2012 at 17:55
  • I see you are really curious. :) I have added explanation what those commands do, feel free to ask if anything is unclear. Given you have use standard configuration, you shouldn't run into any problems.
    – jnv
    May 4, 2012 at 18:31
  • Ohh yes ! I am Curious :D. And Thank you for trying to clear things up. Ok now you have allowed me to ask further questions, so here is what I need to know more: Why I need to use a $Private variable ? How I run the command ? I have tried copy pasting it ($ PRIVATE=cat ~/.ecryptfs/Private.mnt 2>/dev/null || echo $HOME/Private) and It outputted "$ Command Not Found !" May 5, 2012 at 17:02
  • Next thing is, why I need to make $Private writable ? Is it the variable which holds the path or it is the Folder itself ? I knew how to see hidden folders, and Private directory is automatically mounted at my Login. When Im trying to remove ecryptfs and that lib file it shows an error which states that "Device is busy". May 5, 2012 at 17:06
1

I followed the instructions given in https://help.ubuntu.com/community/EncryptedPrivateDirectory#Using%20in%20conjunction%20with%20Auto-login in the section "How to Remove an Encrypted Private Directory Setup".

Notes:

  • You must be logged in the correct user session, I mean the one you don`t want to be encrypted.
  • BACKUP all the data in your Private folder (/home/your-user-name/Private normally.
  • Delete ecryptfs (step 5) is optional, with the previous steps it`s ok.

If you don`t have access to the data in your Private folder, or the file names are encrypted, then follow this steps:

Note: This procedure is an alternative I found by myself (with a friend help) because all I read in forums doesn`t work for me.

  1. $ sudo ecryptfs-recover-private
  2. $ [sudo] password for "user-name"
  3. $ INFO: Searching for encrypted private directories (this might take a while)...
  4. INFO: Found [/home/.ecryptfs/"user-name"/.Private].
  5. Try to recover this directory? [Y/n]: Y
  6. INFO: Found your wrapped-passphrase...
  7. Do you know your LOGIN passphrase? [Y/n]: Y
  8. INFO: Enter your LOGIN passphrase... Passphrase:*LOGIN PASSPHRASE of "user-name"
  9. Inserted auth tok with sig [xxxxxxxxxxxxxxx] into the user sesiong keyring
  10. INFO: Success! Private data mounted read-only at [/tmp/ecryptfs.yyyyyyyy].
  11. $ sudo nautilus /tmp/ecryptfs.yyyyyyyy/

The last command will open the folder /tmp/ecryptfs.yyyyyyyy were you can acess your decrypted data in order to make the backup. Then you close the folder and close the terminal.

1
  • I have access to Private folder and it is automatically mounted at statup. May 4, 2012 at 18:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .