Commit 856f008e authored by Vitaly Lipatov's avatar Vitaly Lipatov

add add_gitkey.sh

parent 980c8163
#!/bin/sh
USERNAME=$1
GITHOST=$2
USERDESC="$3"
docmd()
{
echo "\$ $@"
"$@"
}
fatal()
{
echo -e "Error: $@" >&2
exit 1
}
Help="Usage: $0 USERNAME GITHOST 'Name Lastname'"
if [ "$USERNAME" = "-h" ]; then
echo -e "$Help"
exit
fi
if [ -z "$USERNAME" ] || [ -z "$GITHOST" ] || [ -z "$USERDESC" ]; then
fatal "$Help"
fi
USERKEY=$(ssh rooter@server get pubkey $USERNAME)
[ -n "$USERKEY" ] || fatal "Can't get ssh key"
ssh $USER@$GITHOST echo || fatal "Host $GITHOST is not sshed"
echo "$USERKEY" | ssh $USER@$GITHOST tee $USERNAME.key || fatal
ssh $USER@$GITHOST sudo girar-add $USERNAME $USERNAME.key "$USERDESC" || fatal
ssh $USER@$GITHOST rm -f $USERNAME.key || fatal
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment