Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (40 sloc) 1012 Bytes
#!/bin/bash
KEY="$1"
SECUREDEVICE="/dev/${2:-sdc1}"
SECUREDEVICENAME="securegpg"
SECUREHOME="/media/securegpg"
SECUREGPGDIR="$SECUREHOME/.gnupg"
PrintUsage(){
cat <<< EOI
Usage:
securegpgsign key [devicename]
securegpgsign -h | --help
Default Device name is sdc1
Examples:
securegpgsign 0x23FOOBA2
securegpgsign 0x23FOOBA2 sde
EOI
}
if [[ $1 == "-h" || $1 == "--help" ]]
then
PrintUsage
fi
if (($# < 1))
then
PrintUsage
exit 1
fi
gpg --recv-key "$KEY"
gpg --fingerprint "$KEY"
echo "Is the fingerprint correct?"
echo "Press Enter to continue or ^C to canel."
read
cryptsetup luksOpen "$SECUREDEVICE" "$SECUREDEVICENAME"
mount "/dev/mapper/$SECUREDEVICENAME" "$SECUREHOME"
gpg --export "$KEY" | gpg --homedir "$SECUREGPGDIR" --import
gpg --homedir "$SECUREGPGDIR" --sign-key "$KEY"
gpg --homedir "$SECUREGPGDIR" --send-keys "$KEY"
gpg --homedir "$SECUREGPGDIR" --export "$KEY" | gpg --import
pkill gpg-agent
umount "$SECUREHOME"
cryptsetup luksClose "/dev/mapper/$SECUREDEVICENAME"