Created
October 31, 2020 01:17
-
-
Save mattlevan/18b475fccaedf0421d0c48a93d6b4d35 to your computer and use it in GitHub Desktop.
Install apt packages on multiple computers simultaneously
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Dependencies: | |
# - Each machine must have openssh-server installed | |
# - Each machine must have key-based SSH authentication configured | |
# - Each machine must have | |
declare -a MACHINES=( | |
"localhost" | |
"nonexistent" | |
"tobys-machine" | |
"etc" | |
) | |
PRIVILEGED_USER="stem" | |
PACKAGES="vim libreoffice python3" | |
for MACHINE in ${MACHINES[@]}; | |
do | |
echo "Installing packages on $MACHINE..." | |
CMD="ssh $PRIVILEGED_USER@$MACHINE 'sudo apt-get install -y $PACKAGES'" | |
exec $CMD | |
echo "Finished installing packages on $MACHINE." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment