scripts
Valentin 2023-09-14 23:35:34 +02:00 committed by GitHub
parent 3525bf21b7
commit 8700c67a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 26 deletions

View File

@ -2,7 +2,7 @@
. /opt/accessgate_agent/config.txt
if [ $user == "accessgatemultiuser"]
if [ "$user" = "accessgatemultiuser" ]
then
tmp_file=/opt/accessgate_agent/tmp_user.txt
old_file=/opt/accessgate_agent/old_user.txt
@ -11,27 +11,28 @@ then
[[ -f filename ]] || touch $old_file
cmp --silent $old_file $tmp_file || isDifferent=true
if [ isDifferent = "true" ]
then
for x in $(head $old_file)
do
rm /home/$x/.ssh/authorized_keys
done
fi
for x in $(head $tmp_file)
do
userPath=$x
echo $x
if [ $x != "root" ]
then
userPath=home/$x
fi
mkdir -p $userPath/.ssh
curl -o $userPath/.ssh -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/key/$x
mkdir -p /home/$x/.ssh
curl -o /home/$x/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/key/$x
done
mv $tmp_file $old_file
else
if [ $user != "root" ]
then
userPath=home/$x
fi
mkdir -p $userPath/.ssh
curl -o $userPath/.ssh -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/allKeys
mkdir -p /$user
mkdir -p /$user/.ssh/
curl -o /$user/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/allKeys
fi
mv $tmp_file $old_file