Re-design of the original gocryptfs code to work as a library.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.2 KiB

Mounting gocryptfs on login using pam_mount

This works on Fedora 24 with active SELinux. Feedback on other platforms is welcome.


Copy the gocryptfs binary and gocryptfs_pam_mount.bash into /usr/local/bin .

The bash wrapper is neccessary because of the different calling conventions between pam_mount and gocryptfs.

Create a gocryptfs filesystem:

$ mkdir /home/testuser/cipher /home/testuser/plain
$ gocryptfs -init /home/testuser/cipher

pam_mount config

Put the following into /etc/security/pam_mount.conf.xml, just before the closing </pam_mount> tag at the bottom:

<volume user="testuser" fstype="fuse" options="defaults"
mountpoint="/home/%(USER)/plain" />

Replace testuser with your user name.

If you want to disable the display of the masterkey on mount, replace options="defaults" with options="quiet".

PAM config

An example /etc/pam.d/login on Fedora 24 is shown below. pam_mount MUST be called AFTER open because that puts us in the right SELinux context. If are logging in via gcm, also add the line in /etc/pam.d/gdm-password.

auth       substack     system-auth
auth       include      postlogin
account    required
account    include      system-auth
password   include      system-auth
session    required close
session    required
session    optional
session    required open
session    required
# vvv insert pam_mount here
session optional
# ^^^ insert pam_mount here
session    optional force revoke
session    include      system-auth
session    include      postlogin
-session   optional

Encrypting the whole home directory

Use this volume definition in /etc/security/pam_mount.conf.xml:

<volume user="testuser-whole-home" fstype="fuse" options="nonempty,allow_other"
mountpoint="/home/%(USER)" />

Replace testuser-whole-home with your user name.