46 lines
877 B
Bash
46 lines
877 B
Bash
#!/bin/sh
|
|
# cassh - Manager for an OpenSSH Certification Authority
|
|
#
|
|
# Written in 2022 by Lucas
|
|
#
|
|
# To the extent possible under law, the author(s) have dedicated all
|
|
# copyright and related and neighboring rights to this software to the
|
|
# public domain worldwide. This software is distributed without any
|
|
# warranty.
|
|
# You should have received a copy of the CC0 Public Domain Dedication
|
|
# along with this software. If not, see
|
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
usage()
|
|
{
|
|
cat - <<EOF >&2
|
|
Usage:
|
|
${0##*/} private_key cassh_command [options ...]
|
|
EOF
|
|
exit 1
|
|
}
|
|
|
|
if [ $# -lt 2 ]; then
|
|
usage
|
|
fi
|
|
|
|
cassh_command=$2
|
|
needs_agent=false
|
|
case $cassh_command in
|
|
issue|revoke)
|
|
needs_agent=true
|
|
;;
|
|
esac
|
|
|
|
if $needs_agent; then
|
|
ssh-agent sh -s "$@" <<'EOF'
|
|
ssh-add -q "$1" && shift && cassh "$@"
|
|
rc=$?
|
|
ssh-agent -k >/dev/null
|
|
exit $rc
|
|
EOF
|
|
else
|
|
shift
|
|
cassh "$@"
|
|
fi
|