Export backup key with password

This commit is contained in:
Bob Mottram 2017-06-23 18:18:08 +01:00
parent 22e6e4ae62
commit 6f54f4b515
1 changed files with 6 additions and 1 deletions

View File

@ -155,6 +155,8 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]];
echo "$gpgkey" echo "$gpgkey"
exit 735282 exit 735282
fi fi
echo ''
echo $'Enter your gpg private key passphrase:'
gpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_ID) gpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_ID)
if [[ "$gpgprivkey" == *"$gpgerrstr"* ]]; then if [[ "$gpgprivkey" == *"$gpgerrstr"* ]]; then
echo $'Problem exporting private gpg key' echo $'Problem exporting private gpg key'
@ -163,13 +165,16 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]];
exit 629362 exit 629362
fi fi
# Dummy password to get around not being able to create a key without passphrase
BACKUP_DUMMY_PASSWORD='backup'
backupgpgkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export $GPG_BACKUP_ID) backupgpgkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export $GPG_BACKUP_ID)
if [[ "$backupgpgkey" == *"$gpgerrstr"* ]]; then if [[ "$backupgpgkey" == *"$gpgerrstr"* ]]; then
echo $'Problem exporting public gpg backup key' echo $'Problem exporting public gpg backup key'
echo "$backupgpgkey" echo "$backupgpgkey"
exit 735282 exit 735282
fi fi
backupgpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_BACKUP_ID) backupgpgprivkey=$(echo "$BACKUP_DUMMY_PASSWORD" | gpg --batch --passphrase-fd 0 --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_BACKUP_ID)
if [[ "$backupgpgprivkey" == *"$gpgerrstr"* ]]; then if [[ "$backupgpgprivkey" == *"$gpgerrstr"* ]]; then
echo $'Problem exporting private gpg backup key' echo $'Problem exporting private gpg backup key'
echo "$backupgpgprivkey" echo "$backupgpgprivkey"