Encrypting data with eCryptfs

 

Encryption is probably the best way to secure sensitive data and protect your private files from unauthorized access. eCryptfs is a Linux tool to create an encrypted directory (user home directory encryption is also supported, see below). eCryptfs acts as a stacked filesystem and it works by mounting an encrypted directory to another unencrypted mount point at runtime.
 
This is also a topic for LPIC-303 exam:
 
331.3 Encrypted File Systems
  • Use eCryptfs to encrypt file systems, including home directories and PAM integration

Installation

sudo apt-get install ecryptfs-utils

ecryptfs-utils package installation example (Ubuntu).

Creating an encrypted directory

sudo mount -t ecryptfs ~/private/ ~/private/

Using mount command and selecting ecryptfs as the filesystem. 

Encrypting home directory

sudo ecryptfs-migrate-home -u test

Note: user has to be logged out during this operation. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PAM integration

There is a pam module called pam_ecryptfs, which can be used to unwrap an ecryptfs mount passphrase stored in ~/.ecryptfs/passphrase and automatically mount a protected directory.

/etc/pam.d/common-auth
auth    required        pam_ecryptfs.so unwrap


/etc/pam.d/common-session
session optional        pam_ecryptfs.so unwrap



Comments

Popular posts from this blog

Splunk: Authentication with Discord? Wht not! (OAuth 2.0)

Study notes: Understanding DNSSEC

Linux: auditd fundamentals