Skip to content

Instantly share code, notes, and snippets.

@carld
Last active August 29, 2015 14:26
Show Gist options
  • Save carld/60b2785f6f26f8151642 to your computer and use it in GitHub Desktop.
Save carld/60b2785f6f26f8151642 to your computer and use it in GitHub Desktop.
prompt for a command to run on multiple hosts via ssh
HOSTS=( host1 host2 )
USER=me
while read -e -p "-> " CMD </dev/tty
do
for host in "${HOSTS[@]}"; do
echo $host
ssh $USER@$host -C $CMD
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment