Tidying backup key creation
This commit is contained in:
parent
b198c6312f
commit
9cbf25aec9
|
@ -6328,26 +6328,29 @@ function configure_backup_key {
|
||||||
apt-get -y install gnupg
|
apt-get -y install gnupg
|
||||||
|
|
||||||
BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")
|
BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")
|
||||||
if [ "$?" = "0" ]; then
|
if [ $BACKUP_KEY_EXISTS != *"error"* ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate a GPG key for backups
|
# Generate a GPG key for backups
|
||||||
echo 'Key-Type: 1' > /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
echo 'Key-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
echo 'Subkey-Type: 1' >> /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
echo 'Subkey-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
echo "Name-Real: $MY_NAME" >> /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 'Expire-Date: 0' >> /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
su -c "gpg --batch --gen-key /home/$MY_USERNAME/gpg-genkey.conf" - $MY_USERNAME
|
|
||||||
shred -zu /home/$MY_USERNAME/gpg-genkey.conf
|
|
||||||
BACKUP_KEY_EXISTS=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\"" - $MY_USERNAME)
|
BACKUP_KEY_EXISTS=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\"" - $MY_USERNAME)
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ $BACKUP_KEY_EXISTS == *"error"* ]; then
|
||||||
echo 'Backup key could not be created'
|
echo 'Key-Type: 1' > /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
exit 43382
|
echo 'Key-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
echo 'Subkey-Type: 1' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
echo 'Subkey-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
echo "Name-Real: $MY_NAME" >> /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 'Expire-Date: 0' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
su -c "gpg --batch --gen-key /home/$MY_USERNAME/gpg-genkey.conf" - $MY_USERNAME
|
||||||
|
shred -zu /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
BACKUP_KEY_EXISTS=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\"" - $MY_USERNAME)
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
echo 'Backup key could not be created'
|
||||||
|
exit 43382
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
MY_BACKUP_KEY_ID=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\" | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
MY_BACKUP_KEY_ID=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\" | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||||
echo "Backup key: $MY_BACKUP_KEY_ID"
|
echo "Backup key: $MY_BACKUP_KEY_ID"
|
||||||
|
|
Loading…
Reference in New Issue