Ubuntu 22.04 Specific folder Encryption

From Notes_Wiki
Revision as of 09:47, 31 May 2025 by Kamal (talk | contribs)

Home > Ubuntu > Ubuntu 22.04 > Ubuntu 22.04 Specific folder Encryption

We can encrypt a particular folder (not the entire drive) on Ubuntu 22.04 using eCryptfs. This method allows you to mount a directory as an encrypted filesystem, so only users with the correct passphrase can access the data. Here's a step-by-step guide:

Install eCryptfs Utilities

apt install ecryptfs-utils

Prepare the Directory

Create a new, empty directory that you want to encrypt. Do not encrypt a directory that already contains data, as existing data will not be encrypted or may become inaccessible. Move any existing data out first.

mkdir ~/myencryptedfolder

Mount the Directory as Encrypted

Mount the directory to itself with eCryptfs:

#sudo mount -t ecryptfs ~/myencryptedfolder ~/myencryptedfolder