I just want to change the username of a user with an encrypted home directory. Is there a simple way instead of the suggested restoring and so forth?
Asked
Active
Viewed 535 times
1 Answers
5
- It's best to unmount your home directory and execute the commands from another administrator account on the computer. You could use
ecryptfs-umount-privateor just reboot to unmount the directory. Change the login name and directory name from
old_usertonew_user:sudo usermod -l new_user -m -d /home/new_user old_userHere comes the important part for the proper configuration:
- There exists a file named
/home/.ecryptfs/$USER/.ecryptfs/Private.mntit usually contains the following:/home/$USER The following symlinks exist in your home directory when eCryptfs is not mounted:
.ecryptfs -> /home/.ecryptfs/$USER/.ecryptfs .Private -> /home/.ecryptfs/$USER/.PrivateMake sure that
$USERin all these instances reflects the changes you intended to make, e.g.new_user. You can usenanoto edit text files andln -sto create new symlinks.
- There exists a file named
You should be able to login again. I just tried it on my own. If you cannot log in through the GUI try from the terminal and check again that everything is in place.
LiveWireBT
- 28,405
- 26
- 107
- 221
-
Which version of Ubuntu does this work on? (Just in case it doesn't work on a future/past version) – Xen2050 Dec 31 '18 at 23:41
-
@Xen2050 Based on [this](https://askubuntu.com/a/298251/40581) answer I'd say it should work on all non-EOL releases. In this example though I actually used Fedora 29. I made similar modifications to Ubuntu hosts years ago like providing an unencrypted `.ssh/authorized_keys` file for remote login, so I'd say once you understood where your data and configuration is and how the individual parts come together it's pretty basic and solid. – LiveWireBT Jan 01 '19 at 00:42
-
This worked for me, except renaming the `/home/.ecryptfs/$USER` directory. If I rename it, I can no longer access the directory, regardless if I change the reference in the files in my home directory. No biggie though, I don't mind if that directory has a different name, it's hidden inside `.ecryptfs` directory anyway. – Alex Burdusel Dec 10 '22 at 10:32