Files
cdba/shell/post-receive
Bjorn Andersson ffc91a6bf2 cdba-shell: Add some simple scripts for user maintenance
Introduce some scripts to allow storing users public keys in a git and
some hooks such that when this is pushed to the server the
authorized_keys file is re-generated.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2022-08-18 23:07:40 -05:00

33 lines
692 B
Bash

#!/bin/sh -e
#
# Generate new authorized_keys
#
AUTHORIZED_KEYS=$HOME/.ssh/authorized_keys
AUTHORIZED_TMP=$HOME/.ssh/authorized_keys.tmp
:> $AUTHORIZED_TMP
git cat-file -p main:keydir | while read LINE; do
TYPE=$(echo $LINE | awk '{ print $2 }')
NAME=$(echo $LINE | awk '{ print $4 }')
if [ "$TYPE" != "blob" ]; then
continue
fi
USER=$(basename $NAME .pub)
PUBKEY=$(git cat-file blob main:keydir/$NAME)
echo "command=\"$HOME/bin/cdba-shell $USER\" $PUBKEY" >> $AUTHORIZED_TMP
done
mv $AUTHORIZED_TMP $AUTHORIZED_KEYS
#
# Install .cdba
#
git cat-file blob main:cdba > $HOME/.cdba
#
# Install admins list
#
git cat-file blob main:admins > $HOME/admins