Set password when creating backup key
This commit is contained in:
parent
d4ede9cad6
commit
50d99f06eb
|
@ -78,8 +78,6 @@ function configure_backup_key {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
backup_create_password
|
|
||||||
|
|
||||||
# Generate a GPG key for backups
|
# Generate a GPG key for backups
|
||||||
BACKUP_KEY_EXISTS=$(gpg_key_exists "$MY_USERNAME" "$MY_NAME (backup key)")
|
BACKUP_KEY_EXISTS=$(gpg_key_exists "$MY_USERNAME" "$MY_NAME (backup key)")
|
||||||
if [[ $BACKUP_KEY_EXISTS == "no" ]]; then
|
if [[ $BACKUP_KEY_EXISTS == "no" ]]; then
|
||||||
|
@ -91,21 +89,23 @@ function configure_backup_key {
|
||||||
echo "Name-Email: $MY_EMAIL_ADDRESS" >> /home/$MY_USERNAME/gpg-genkey.conf
|
echo "Name-Email: $MY_EMAIL_ADDRESS" >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
echo "Name-Comment: backup key" >> /home/$MY_USERNAME/gpg-genkey.conf
|
echo "Name-Comment: backup key" >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
echo 'Expire-Date: 0' >> /home/$MY_USERNAME/gpg-genkey.conf
|
echo 'Expire-Date: 0' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
echo "Passphrase: $BACKUP_DUMMY_PASSWORD" >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/gpg-genkey.conf
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
echo $'Backup key does not exist. Creating it.'
|
echo $'Backup key does not exist. Creating it.'
|
||||||
su -m root -c "gpg --homedir /home/$MY_USERNAME/.gnupg --batch --passphrase-fd $BACKUP_PASSWORD_FILE --full-gen-key /home/$MY_USERNAME/gpg-genkey.conf" - $MY_USERNAME
|
su -m root -c "gpg --homedir /home/$MY_USERNAME/.gnupg --batch --full-gen-key /home/$MY_USERNAME/gpg-genkey.conf" - $MY_USERNAME
|
||||||
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
|
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
|
||||||
|
|
||||||
shred -zu /home/$MY_USERNAME/gpg-genkey.conf
|
shred -zu /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
echo $'Checking that the Backup key was created'
|
echo $'Checking that the Backup key was created'
|
||||||
BACKUP_KEY_EXISTS=$(gpg_key_exists "$MY_USERNAME" "$MY_NAME (backup key)")
|
BACKUP_KEY_EXISTS=$(gpg_key_exists "$MY_USERNAME" "$MY_NAME (backup key)")
|
||||||
if [[ $BACKUP_KEY_EXISTS == "no" ]]; then
|
if [[ $BACKUP_KEY_EXISTS == "no" ]]; then
|
||||||
backup_remove_password
|
|
||||||
echo $'Backup key could not be created'
|
echo $'Backup key could not be created'
|
||||||
exit 43382
|
exit 43382
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
backup_create_password
|
||||||
|
|
||||||
MY_BACKUP_KEY_ID=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\"" - $MY_USERNAME | sed -n '2p' | sed 's/^[ \t]*//')
|
MY_BACKUP_KEY_ID=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\"" - $MY_USERNAME | sed -n '2p' | sed 's/^[ \t]*//')
|
||||||
echo "Backup key: $MY_BACKUP_KEY_ID"
|
echo "Backup key: $MY_BACKUP_KEY_ID"
|
||||||
MY_BACKUP_KEY=/home/$MY_USERNAME/backup_key
|
MY_BACKUP_KEY=/home/$MY_USERNAME/backup_key
|
||||||
|
|
Loading…
Reference in New Issue