Simplify key recovery from remote servers

This commit is contained in:
Bob Mottram 2015-12-09 16:32:30 +00:00
parent 3f91711e93
commit bbe5d6a9e0
1 changed files with 3 additions and 18 deletions

View File

@ -135,24 +135,9 @@ function restore_database_from_friend {
fi fi
} }
# Social key management. Note that because this a restore from only # Social key management
# one domain you are only going to download a single fragment for each gpg key. # Recover any key fragments and reconstruct the gpg key
# To recover all fragments use the recoverkey command ${PROJECT_NAME}-recoverkey -u ${ADMIN_USERNAME} -l /home/${ADMIN_USERNAME}/backup.list
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" ]]; then
# Retrieve key fragments for $USERNAME
/usr/bin/sshpass -p "$REMOTE_PASSWORD" scp -r -P $REMOTE_SSH_PORT $REMOTE_SERVER/.gnupg_fragments_$USERNAME /home/$USERNAME/
if [ -d /home/$USERNAME/.gnupg_fragments_$USERNAME ]; then
if [ -d /home/$USERNAME/.gnupg_fragments ]; then
cp /home/$USERNAME/.gnupg_fragments_$USERNAME/* /home/$USERNAME/.gnupg_fragments
rm -rf /home/$USERNAME/.gnupg_fragments_$USERNAME
else
mv /home/$USERNAME/.gnupg_fragments_$USERNAME /home/$USERNAME/.gnupg_fragments
fi
fi
fi
done
copy_gpg_keys copy_gpg_keys