This repository has been archived on 2024-02-18. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-role-ssh-ca/templates/ssh_ca.sh.j2

29 lines
619 B
Text
Raw Normal View History

2023-04-23 21:34:36 +00:00
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
host() {
CAKEY="$2"
PUBKEY="$3"
HOST="$4"
2023-04-23 21:34:36 +00:00
echo "$PUBKEY" > {{ ssh_ca_dir }}/"$HOST".pub
ssh-keygen -h -s {{ ssh_ca_dir }}/keys/"$CAKEY" -I "$HOST" -n "$HOST" {{ ssh_ca_dir }}/"$HOST".pub
2023-04-23 21:34:36 +00:00
cat {{ ssh_ca_dir }}/"$HOST"-cert.pub
rm {{ ssh_ca_dir }}/"$HOST"*.pub
}
user() {
CAKEY="$2"
PUBKEY="$3"
HOST="$4"
PRINCIPALS="$5"
2023-04-23 21:34:36 +00:00
echo "$PUBKEY" > {{ ssh_ca_dir }}/"$HOST".pub
ssh-keygen -s {{ ssh_ca_dir }}/keys/"$CAKEY" -I "$HOST" -n "$HOST","$PRINCIPALS" {{ ssh_ca_dir }}/"$HOST".pub
2023-04-23 21:34:36 +00:00
cat {{ ssh_ca_dir }}/"$HOST"-cert.pub
rm {{ ssh_ca_dir }}/"$HOST"*.pub
}
"$1" "$@"