Few days ago we showed you how to change your home folder in Ubuntu so that only authorized users may see your content. We said that the adduser utility creates user’s directories in such a way that make them world readable. This means that any all users who have accounts on the machine will be able to browse and view content in your home directory by default,
To read our previous post on this, please click here. In that post, we also showed you which permission settings to apply to your home folder to that it isn’t browseable by anyone.
In this blog post, you can accomplish the same by encrypting your home folder. When encrypt your home folder, unauthorized users will also not be able to browse or access your home directories.
Encrypting your home folder may not be suitable for everyone in every environment so make sure you’re absolutely certain that you want to use this feature in Ubuntu before actually using it.
To get started encrypting your home directory, logon to Ubuntu and run the commands below.
sudo apt-get install ecryptfs-utils
Since your can’t be logged-in while encrypting your exiting home folder, you must create a temporary account and login with it. Then run the commands below to encrypt your home folder. Replace USERNAME with your account name.
sudo ecryptfs-migrate-home -u USERNAME
When you login as the temporary user, run the su command plus your username to run commands as you, since your account has root / admin rights. You’ll be prompted for your password.
su USERNAMEReplace USERNAME with the username of the account that has root / admin rights.
After that, encrypt your home folder by running the ecryptfs-migrate-home –u USERNAME command.
To create a user in Ubuntu, run the commands below.
sudo adduser USERNAME
To delete user in Ubuntu, run the commands below.
sudo deluser USERNAME
When you login, you’ll see the screen shot below giving you more information about your encrypted home folder.
To create future users with encrypted home directory, run the commands below.
adduser –encrypt-home USERNAME
Enjoy!
Frequently Asked Questions
How can I protect my home folders in Ubuntu from unauthorized access?
You can protect your home folders in Ubuntu from unauthorized access by encrypting them using the ecryptfs-utils package.
What is the command to encrypt a home folder in Ubuntu?
To encrypt a home folder in Ubuntu, you can use the command sudo ecryptfs-migrate-home -u USERNAME, replacing USERNAME with your account name.
Is encrypting the home folder in Ubuntu suitable for all users and environments?
Encrypting the home folder in Ubuntu may not be suitable for everyone in every environment, so it's important to ensure that you want to use this feature before proceeding.
How can I create a temporary account to encrypt my home folder in Ubuntu?
You can create a temporary account in Ubuntu by using the sudo adduser USERNAME command, replacing USERNAME with the desired account name.
What permissions should be applied to the home folder to prevent unauthorized browsing in Ubuntu?
To prevent unauthorized browsing in Ubuntu, apply permission settings to your home folder to ensure it is not browseable by anyone.
Can all users with accounts on the machine browse and view content in the home directory by default in Ubuntu?
Yes, all users with accounts on the machine can browse and view content in the home directory by default in Ubuntu, unless specific permission settings are applied.
How can I run commands as a user with root/admin rights in Ubuntu?
To run commands as a user with root/admin rights in Ubuntu, use the su USERNAME command, replacing USERNAME with the username of the account that has root/admin rights.
What package should I install to encrypt my home folder in Ubuntu?
To encrypt your home folder in Ubuntu, you should install the ecryptfs-utils package using the command sudo apt-get install ecryptfs-utils.