sshca: First version of role

This commit is contained in:
Timo Makinen 2024-03-23 18:19:00 +00:00
parent 0618cde4d1
commit 917674bac8
3 changed files with 63 additions and 0 deletions

26
roles/sshca/files/signcert.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
set -eu
umask 022
if [ $# -ne 1 ]; then
echo "Usage: $(basename "$0") <pubkey>" 1>&2
exit 1
fi
_basedir="/srv/sshca"
_name="$1"
if ! echo "$_name" | grep -Eq '.foo.sh$'; then
echo "ERROR: Only '*.foo.sh' certificates are allowed" 1>&2
exit 1
fi
if [ ! -f "/srv/ansible/facts/${_name}" ]; then
echo "ERROR: Cannot find host '${_name}'" 1>&2
exit 1
fi
ssh-keygen -s "${_basedir}/ca/ca" -I "$_name" -n "$_name" -V -5m:+365d -h \
"${_basedir}/pubkeys/${_name}.pub"