soios/contestops/assign-user.sh

21 lines
560 B
Bash
Raw Permalink Normal View History

2024-05-09 22:45:53 +02:00
#!/bin/bash
machinename="$1"
username="$2"
machineusername=contestant
userline=$(grep "^$username;" contestants.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 -F local.ssh_config "$machinename" chfn --full-name "\"$fullname\"" $machineusername
# Install client certificate
scp -F local.ssh_config "certs/$username.p12" "$machinename:/home/$machineusername/clientcert.p12"
ssh -F local.ssh_config "$machinename" install-client-cert $machineusername