title: SSH to multiple hosts at once
body: <p>I have a script which loops through a list of hosts, connecting to each of them with SSH using an RSA key, and then saving the output to a file on my local machine - this all works correctly. However, the commands to run on each server take a while (~30 minutes) and there are 10 servers. I would like to run the commands in parallel to save time, but can't seem to get it working. Here is the code as it is now (working):</p>
  
  <pre><code>for host in $HOSTS; do
      echo "Connecting to $host"..
      ssh -n -t -t $USER@$host "/data/reports/formatted_report.sh"
  done
  </code></pre>
  
  <p>How can I speed this up?</p>