This repository has been archived on 2023-12-26. You can view files and clone it, but cannot push or open issues or pull requests.
hermes/ansible/roles/ca/files/ca.sh

30 lines
530 B
Bash
Raw Normal View History

2023-04-04 07:26:16 +00:00
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
HOSTCAKEY=/root/.ssh/host_ca_key
USERCAKEY=/root/.ssh/user_ca_key
host() {
PUBKEY="$2"
HOST="$3"
echo "$PUBKEY" > /tmp/"$HOST".pub
ssh-keygen -h -s "$HOSTCAKEY" -I "$HOST" -n "$HOST" /tmp/"$HOST".pub
cat /tmp/"$HOST"-cert.pub
rm /tmp/"$HOST"*.pub
}
user() {
PUBKEY="$2"
HOST="$3"
PRINCIPALS="$4"
echo "$PUBKEY" > /tmp/"$HOST".pub
ssh-keygen -s "$USERCAKEY" -I "$HOST" -n "$HOST","$PRINCIPALS" /tmp/"$HOST".pub
cat /tmp/"$HOST"-cert.pub
rm /tmp/"$HOST"*.pub
}
"$1" "$@"