Skip to content

Instantly share code, notes, and snippets.

@samatjain
Last active May 18, 2017 18:50
Show Gist options
  • Star 38 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save samatjain/987f946b29724401148c to your computer and use it in GitHub Desktop.
Save samatjain/987f946b29724401148c to your computer and use it in GitHub Desktop.
Setting up a encrypted drive on Amazon Cloud Drive w/ EncFS and acd_cli

Environment

export ACD_LOCAL=$HOME/.cache/Amazon-Cloud-Drive

# To use this file later
export ENCFS6_CONFIG=$ACD_LOCAL/encfs6.xml

Setup

mkdir -p \
$ACD_LOCAL/local.encrypted \
$ACD_LOCAL/local.plaintext \
$ACD_LOCAL/cloud.encrypted \
$ACD_LOCAL/cloud.plaintext

# On first run, you'll need to setup EncFS. Just use the defaults.
# Since we don't upload the key, it's OK to use an empty passphrase
# Useful options, case insentive file names, 4K blocks, path-independent filenames
encfs \
$ACD_LOCAL/local.encrypted \
$ACD_LOCAL/local.plaintext

acd_cli mount --modules="subdir,subdir=/Encrypted" \
$ACD_LOCAL/cloud.encrypted

# Backup key & configuration for safe-keeping
# TODO: this shouldn't be in ~/.cache/!
ln \
$ACD_LOCAL/local.encrypted/.encfs6.xml \
$ACD_LOCAL/encfs6.xml


encfs \
$ACD_LOCAL/cloud.encrypted \
$ACD_LOCAL/cloud.plaintext

unionfs-fuse -o cow \
$ACD_LOCAL/local.plaintext=RW:\
$ACD_LOCAL/cloud.plaintext=RO \
$HOME/Cloud

Sync

# Periodically run:
# (will prevent uploading of key and config to cloud)
acd_cli sync
acd_cli upload -x 4 --exclude-ending encfs6.xml \
$ACD_LOCAL/local.encrypted/* \
/Encrypted/

Garbage collection

# Remove files older than 7 days and empty directories
find $ACD_LOCAL/local.encrypted/ -type f -mtime +7 -print0 | xargs -0 -n256 rm
find $ACD_LOCAL/local.encrypted/ -type d -empty -delete
# Or immediately remove any local files
find $ACD_LOCAL/local.encrypted/ -type f -print0 | xargs -0 -n256 rm

Unmount

# Unmount everything
fusermount -u $HOME/Cloud/
fusermount -u $ACD_LOCAL/cloud.plaintext
fusermount -u $ACD_LOCAL/cloud.encrypted
fusermount -u $ACD_LOCAL/local.plaintext
@triwats
Copy link

triwats commented Dec 1, 2015

Fancy giving some citation to the AMC blog since this is pretty much completely the same steps? Seems only fair considering the hard work they have done to get their guide in order.

https://amc.ovh/

@crack00r
Copy link

Is there anyway to encrypt files, that are in the cloud, and not uploaded everything again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment