Setting Up eCryptFS in Linux

By Zhiqiang Ma On Nov 27, 2012

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 group

If we want to add user zma and eric to ecryptfs group:
# vim /etc/group
Find:
ecryptfs:x:496:
Then change it to:
ecryptfs:x:496:zma,eric

Mount ecryptfs

If we store encrypted file in /home/private directory:
# mount -t ecryptfs /home/private /home/private
Then you can read/write from/to files under /home/private as a normal directory.

Umount ecryptfs

# umount /home/private
Then 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 :)

By: Zhiqiang Ma Last updated: Nov 27, 2012 Views: 603
Tags: , , , ,

About Zhiqiang Ma

Zhiqiang Ma is a PhD candidate at Dep. of CSE, HKUST. He is interested in system software for cloud computing, virtualization of large-scale distributed system, etc. Find Zhiqiang on Facebook, Twitter, LinkedIn and Google+.

Add your comments, share your thoughts

Be nice. Keep it clean. Stay on topic. No spam.