This repository has been archived on 2024-05-18. You can view files and clone it, but cannot push or open issues or pull requests.
soifai/tools/assign-user.sh

21 lines
513 B
Bash
Raw Permalink Normal View History

2022-07-15 11:59:26 +02:00
#!/bin/bash
machinename="$1"
username="$2"
machineusername=contestant
userline=$(grep "^$username;" usernames.csv)
if [ $? -ne 0 ]; then
echo "User $username not found"
exit 1
fi
fullname=$(echo "$userline" | cut "-d;" -f2)
# Set real name of machine user
ssh root@"$machinename" chfn --full-name "\"$fullname\"" $machineusername
# Install client certificate
scp "certs/$username.p12" "root@$machinename:/home/$machineusername/clientcert.p12"
ssh root@"$machinename" install-client-cert $machineusername