In the construct
something |
while read x; do
ssh ...
done
the standard input as seen by the while loop is the output of something.
The default behavior of ssh is to read standard input. This allows you to do things like
cat id_rsa.pub | ssh new_box "cat - >> ~/.ssh/authorized_keys"
Now, with that being said, when the first value is read, the first ssh command will read the entire input from something. Then, by the time ssh finishes, there is no output left, and read stops.
The fix is ssh -n ... e.g.
cat /etc/hosts | awk '{print $2}' | while read x; do
ssh -n $x "do_something_on_the_machine"
done