Skip to content

Instantly share code, notes, and snippets.

@ruxkor
Created February 6, 2012 12:03
Show Gist options
  • Save ruxkor/1751766 to your computer and use it in GitHub Desktop.
Save ruxkor/1751766 to your computer and use it in GitHub Desktop.
mount ecryptfs home directory
#!/bin/bash
# ecryptFS mount script
# taken and slightly modified version
# original at http://superuser.com/questions/227713/ecryptfs-how-to-mount-a-backup-of-an-encrypted-home-dir
# ROOT should be the parent of the .ecryptfs and .Private folders
if [ ! -d "$1" -o "$2" == "" ]; then
echo "usage: $0 /home/.ecryptfs/USER /mnt/USER"
exit 1
fi
ROOT=$1
TARGET=$2
sudo mkdir -p $TARGET
cd $ROOT
echo Type your password:
PASS=$(ecryptfs-unwrap-passphrase .ecryptfs/wrapped-passphrase | sed s/Passphrase:\ //)
SIG1=$(head -n1 .ecryptfs/Private.sig)
SIG2=$(tail -n1 .ecryptfs/Private.sig)
echo Passphrase:
echo $PASS
echo Signatures:
echo $SIG1
echo $SIG2
echo Should be empty:
sudo keyctl clear @u
sudo keyctl list @u
echo Do not type anything:
echo $PASS | sudo ecryptfs-add-passphrase --fnek
echo Sould have signatures:
sudo keyctl list @u
echo Mounting $ROOT on $TARGET...
sudo mount -t ecryptfs -o key=passphrase,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=yes,ecryptfs_sig=$SIG1,ecryptfs_fnek_sig=$SIG2,passwd=$(echo $PASS) .Private $TARGET
ls $TARGET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment