Skip to content

Instantly share code, notes, and snippets.

@brianlechthaler
Created November 11, 2020 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianlechthaler/432daeb2b7cc594d9d85b8d76934d2b3 to your computer and use it in GitHub Desktop.
Save brianlechthaler/432daeb2b7cc594d9d85b8d76934d2b3 to your computer and use it in GitHub Desktop.
LuksAutoInitGpg.sh
#!/bin/sh
echo "USAGE: ./gpgpw.sh <number of characters> <long key ID to encrypt password to> <output file>"
echo "EXAMPLE: ./gpgpw.sh 1024 DEADBEEF0000FFFF0000FFFF0000FFFF0000FFFF /mnt/encrypted_password.asc /dev/xvdg"
export password=$(pwgen -sy $1 1)
echo $password | cryptsetup luksFormat $4 -
export password=$(echo $password | gpg --encrypt -a -r $2)
echo $password
echo $password > $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment