Last active
August 14, 2020 14:16
-
-
Save swamibluedata/2fe039d1c2d68a3443bf6b0fd2f80b92 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
yum install cryptsetup -y | |
DEVICE_NAME="/dev/xvdb" | |
PASSWORD="dummy password" | |
# Create a secret key file | |
mkdir -p /etc/luks-keys | |
echo "$PASSWORD" > /etc/luks-keys/secret | |
cat /etc/luks-keys/secret | |
echo -n "$PASSWORD" | cryptsetup -q -y -v luksFormat $DEVICE_NAME - | |
echo -n "$PASSWORD" | cryptsetup -v luksAddKey $DEVICE_NAME /etc/luks-keys/secret | |
# Open the device for current session | |
cryptsetup -v luksOpen $DEVICE_NAME encrypted --key-file=/etc/luks-keys/secret | |
# Setup crypttab to open the file on reboot | |
UUID=$(cryptsetup luksDump $DEVICE_NAME | grep "UUID" | cut -d":" -f2 | awk '{$1=$1;print}') | |
echo "encrypted UUID=$UUID /etc/luks-keys/secret luks" >> /etc/crypttab | |
lsblk | |
cat /etc/crypttab | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment