Setting Up eCryptFS in Linux
How to set up eCryptFS in Linux will be introduced in this post. We can store encrypted files in one eCryptFS directory. The content can be seen only after it is mounted as eCryptFS file system. Otherwise, the users can only see garbled characters in the files.
Install eCryptFS tools
# yum install ecryptfs-utils gettext
Add ecryptfs module to Linux Kernel
# modprobe ecryptfs
Add user to ecrypfs groupIf we want to add user zma and eric to ecryptfs group:
# vim /etc/groupFind:
ecryptfs:x:496:Then change it to:
Mount ecryptfsIf we store encrypted file in /home/private directory:
# mount -t ecryptfs /home/private /home/privateThen you can read/write from/to files under /home/private as a normal directory.
# umount /home/privateThen try to open a file under /home/private. Haha, nothing can be found!
When you want to read your find, mount this directory again and your files will be back :)