eCryptfs is a free and open source enterprise cryptographic filesystem disk encryption software for Linux. Using eCryptfs, you can encrypt directory to store the confidential data and mount it on any directory. It supports local filesystem and networked filesystems. It is based on Cryptfs and the FiST framework for stacked filesystems.
How to install eCryptfs on Ubuntu
eCryptfs is available from the default Ubuntu repository. Run below command in the terminal app (ctrl+alt+t) to install the latest version of eCryptfs on your system.
sudo apt install ecryptfs-utils -y
Encrypt Directories With eCryptfs
Create a empty directory in your Home directory. For me its “mani“.
To encrypt the directory mani with ecryptfs, run the below command.
sudo mount -t ecryptfs ~/mani/ ~/mani/
In the “Select key type to use for newly created files” section
Type 2 and press the enter key.
Now type any password and press enter.
Now choose any cipher and press the enter key. For me its “1”
Then Select key bytes (2 for me ) and press the enter key.
Now in enable plaintext passthrough (y/n) [n] option type “n” and press enter.
Enable filename encryption (y/n) [n]: n and press enter.
Would you like to proceed with the mount (yes/no)? :yes
and in order to avoid this warning in the future (yes/no)? : yes
The “mani” directory has been encrypted now and mounted.
You can read and write data saved inside this directory as long as the directory is mounted. Once the directory is unmounted, you can view what is saved in the directory, but can’t read them.
You can unmount using below command.
sudo umount ~/mani