Convert gpg key ID to v2.x format
This commit is contained in:
parent
55e3f4a8ae
commit
7f303823ec
|
@ -1514,7 +1514,8 @@ function create_gpg_subkey {
|
|||
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
|
||||
|
||||
shred -zu /home/$MY_USERNAME/gpg-genkey.conf
|
||||
MY_GPG_SUBKEY_ID=$(su -c "gpg --list-keys $MY_EMAIL_ADDRESS | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
|
||||
MY_GPG_SUBKEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_EMAIL_ADDRESS")
|
||||
|
||||
mark_completed $FUNCNAME
|
||||
}
|
||||
|
|
|
@ -57,9 +57,7 @@ MASTER_PASSWORD=''
|
|||
NO_PASSWORD_STORE_FILE=~/.nostore
|
||||
|
||||
function get_backup_key_id {
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "(backup key)" | \
|
||||
grep 'pub ' | awk -F ' ' '{print $2}' | \
|
||||
awk -F '/' '{print $2}')
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
if [ ${#MY_BACKUP_KEY_ID} -lt 4 ]; then
|
||||
echo $"Error: gpg backup key was not found"
|
||||
return 58213
|
||||
|
|
|
@ -104,16 +104,14 @@ fi
|
|||
if [ ! $MY_EMAIL_ADDRESS ]; then
|
||||
MY_EMAIL_ADDRESS=$MY_USERNAME@$HOSTNAME
|
||||
fi
|
||||
KEYID=$(su -c "gpg --list-keys $MY_EMAIL_ADDRESS | grep 'pub '" - \
|
||||
$MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
|
||||
KEYID=$(su -c "gpg --list-keys $MY_EMAIL_ADDRESS" - $MY_USERNAME | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
if [ ${#KEYID} -lt 4 ]; then
|
||||
echo $"gpg key for $MY_EMAIL_ADDRESS was not found"
|
||||
exit 3682
|
||||
fi
|
||||
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "$MY_NAME (backup key)" | \
|
||||
grep 'pub ' | awk -F ' ' '{print $2}' | \
|
||||
awk -F '/' '{print $2}')
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "$MY_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
if [ ${#MY_BACKUP_KEY_ID} -lt 4 ]; then
|
||||
echo $"gpg backup key for '$MY_NAME' was not found"
|
||||
exit 58213
|
||||
|
|
|
@ -84,7 +84,8 @@ function configure_backup_key {
|
|||
exit 43382
|
||||
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)\"" - $MY_USERNAME | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
echo "Backup key: $MY_BACKUP_KEY_ID"
|
||||
MY_BACKUP_KEY=/home/$MY_USERNAME/backup_key
|
||||
su -m root -c "gpg --homedir /home/$MY_USERNAME/.gnupg --output ${MY_BACKUP_KEY}_public.asc --armor --export $MY_BACKUP_KEY_ID" - $MY_USERNAME
|
||||
|
@ -251,7 +252,8 @@ function backup_directory_to_usb {
|
|||
restart_site
|
||||
exit 6
|
||||
fi
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | grep 'pub ' | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
|
||||
MY_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
if [ ! -d $USB_MOUNT/backup/${2} ]; then
|
||||
mkdir -p $USB_MOUNT/backup/${2}
|
||||
fi
|
||||
|
@ -357,7 +359,8 @@ function backup_directory_to_friend {
|
|||
restart_site
|
||||
exit 43382
|
||||
fi
|
||||
ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | grep 'pub ' | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
|
||||
ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
|
||||
mkdir -p $SERVER_DIRECTORY/backup/${2}
|
||||
fi
|
||||
|
|
|
@ -33,9 +33,9 @@ function gpg_pubkey_from_email {
|
|||
key_email_address=$2
|
||||
key_id=
|
||||
if [[ $key_owner_username != "root" ]]; then
|
||||
key_id=$(su -c "gpg --list-keys $key_email_address | grep 'pub '" - $key_owner_username | head -n 1 | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
else
|
||||
key_id=$(gpg --list-keys $key_email_address | grep 'pub ' | head -n 1 | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||
key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
fi
|
||||
echo $key_id
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue