Skip to content

Instantly share code, notes, and snippets.

@mattlevan
Created October 31, 2020 01:17
Show Gist options
  • Save mattlevan/18b475fccaedf0421d0c48a93d6b4d35 to your computer and use it in GitHub Desktop.
Save mattlevan/18b475fccaedf0421d0c48a93d6b4d35 to your computer and use it in GitHub Desktop.
Install apt packages on multiple computers simultaneously
#!/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