#!/usr/bin/env bash
# Strip the PEM header/footer/newlines from an RSA public key so it can be
# dropped straight into a terraform.tfvars `rsa_public_key` field.
#
# Usage: extract_public_key.sh path/to/rsa_key.pub
set -euo pipefail

if [ $# -ne 1 ]; then
  echo "Usage: $0 path/to/rsa_key.pub" >&2
  exit 1
fi

grep -v -- '-----' "$1" | tr -d '\n'
echo
