title: bash script parallel ssh remote command
body: <p>i have a script that fires remote commands on several different machines through ssh connection. Script goes something like:</p>
  
  <pre><code>for server in list; do
  echo "output from $server"
  ssh to server execute some command
  done
  </code></pre>
  
  <p>The problem with this is evidently the time, as it needs to establish ssh connection, fire command, wait for answer, print it. What i would like is to have script that would try to establish connections all at once and return echo "output from $server" and output of command as soon as it gets it, so not necessary in the list order.</p>
  
  <p>I've been  googling this for a while but didn't find an answer. I cannot cancel ssh session after command run as one thread suggested, because i need an output and i cannot use parallel gnu suggested in other threads. Also i cannot use any other tool, i cannot bring/install anything on this machine, only useable tool is GNU bash, version 4.1.2(1)-release.</p>
  
  <p>Another question is how are ssh sessions like this limited? If i simply paste 5+ or so lines of "ssh connect, do some command" it actually doesn't do anything, or execute only on first from list. (it works if i paste 3-4 lines). Thank you</p>