„authorize-server“ ändern
This commit is contained in:
parent
053350a8e2
commit
0423a4ba73
@ -9,12 +9,12 @@ done < "$SERVER_LIST_FILE"
|
|||||||
|
|
||||||
# Read the public SSH key from the update server
|
# Read the public SSH key from the update server
|
||||||
UPDATE_SERVER="192.168.1.100" # replace with your update server IP address
|
UPDATE_SERVER="192.168.1.100" # replace with your update server IP address
|
||||||
PUBLIC_KEY=$(ssh username@${UPDATE_SERVER} "cat ~/.ssh/id_rsa.pub")
|
PUBLIC_KEY=$(ssh root@${UPDATE_SERVER} "cat ~/.ssh/id_rsa.pub")
|
||||||
|
|
||||||
# Loop through the server list and add the public key to the authorized_keys file of each server
|
# Loop through the server list and add the public key to the authorized_keys file of each server
|
||||||
for SERVER in "${SERVER_LIST[@]}"
|
for SERVER in "${SERVER_LIST[@]}"
|
||||||
do
|
do
|
||||||
# Establish SSH connection to remote server and add the public key to the authorized_keys file
|
# Establish SSH connection to remote server and add the public key to the authorized_keys file
|
||||||
ssh username@${SERVER} "mkdir -p ~/.ssh && echo '${PUBLIC_KEY}' >> ~/.ssh/authorized_keys"
|
ssh root@${SERVER} "mkdir -p ~/.ssh && echo '${PUBLIC_KEY}' >> ~/.ssh/authorized_keys"
|
||||||
echo "Public key added to authorized_keys on server ${SERVER}"
|
echo "Public key added to authorized_keys on server ${SERVER}"
|
||||||
done
|
done
|
Loading…
Reference in New Issue
Block a user