Use Terminal.app to ssh to multiple hosts

Solution 1:

You can write a shell script and put it in ~/.bashrc like this:

function do_some_thing() {
  command="fab -R localhost deploy --set sha=master"
  ssh -t [email protected] -C "$command"
  ssh -t [email protected] -C "$command"
  ssh -t [email protected] -C "$command"
  ssh -t [email protected] -C "$command"
}

However there are various tools you can use for this type of activity, like Chef or Capistrano or various others.

Solution 2:

you can use pdsh, even if you have Chef its going to be faster. with Chef, knife-search (inherent in knife-ssh) is an expensive operations, but you can dump the results of the search knife search node role:base -i > base.nodes and then use pdsh (written in C) to operate on the set (obviously you can do this part without Chef). pdsh -w^base.nodes "sudo whoami" or whatever. pdsh comes with a companion tool dshbak which can summarize the output of the hosts into a convenient report for you, too.

just make sure that you arent doing one-off management at a massive scale using tools like this. its great for auditing and kicking off jobs, but it is not a replacement for config management.