pwgen -1 -n 40 --secure | head -c 40 > /root/foo.key
cryptsetup --verbose --cipher "aes-cbc-essiv:sha256" --key-size 256 --key-file /root/foo.key luksFormat /dev/mapper/foo-enc
cryptsetup open --type luks --key-file /root/foo.key /dev/mapper/foo-enc foo
cryptsetup close foo
Last active
June 22, 2016 21:24
-
-
Save mgax/9b5f8f3670763896a3eecd839016f128 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# apt-get install cryptsetup | |
KEYFILE=/var/local/foo/luks.key | |
ENC_VOLUME=/dev/hostvg/foo-enc | |
VOLUME=foo | |
COMMAND=$1 | |
shift | |
case "$COMMAND" in | |
'setup') | |
set -x | |
exec cryptsetup --verbose --cipher aes-cbc-essiv:sha256 \ | |
--key-size 256 --key-file $KEYFILE luksFormat $ENC_VOLUME | |
;; | |
'open') | |
set -x | |
exec cryptsetup open --type luks --key-file $KEYFILE $ENC_VOLUME $VOLUME | |
;; | |
'close') | |
set -x | |
exec cryptsetup close $VOLUME | |
;; | |
*) | |
echo "Unknown command $COMMAND" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment