# Import OpenPGP keypair
function hydra_import_keys_openpgp {
key="$(keyringer $HYDRA decrypt nodes/$hostname/gpg/key 2> /dev/null | sed -ne '1,$p')"
- key_id="$(echo "$key" | gpg --with-colons | grep sec | cut -d : -f 5)"
+ pubkey="$(keyringer $HYDRA decrypt nodes/$hostname/gpg/key.pub 2> /dev/null | sed -ne '1,$p')"
+ key_id="$(echo "$pubkey" | gpg --with-colons | grep pub | cut -d : -f 5)"
if [ -z "$key" ]; then
echo "Could not find key for $node, skipping."
echo "$key" | sudo gpg --homedir /root/.gnupg --import
echo ""
- echo "Trusting key at $node..."
+ echo "Trusting key $key_id at $node..."
echo ""
printf "trust\n5\ny\nsave\n" | sudo gpg --homedir /root/.gnupg --no-tty --status-fd=2 --command-fd=0 --edit-key $key_id
echo "$key" | sudo gpg --homedir /root/.gnupg --import
echo ""
- echo "Trusting key at $node..."
+ echo "Trusting key $key_id at $node..."
echo ""
printf "trust\n5\ny\nsave\n" | sudo gpg --homedir /root/.gnupg --no-tty --status-fd=2 --command-fd=0 --edit-key $key_id