while read host; do ssh -i id $host command; done < hosts
However, it only executed the remote command on the first host, which was odd. I threw in some echos to see if something strange was happening, but it only confirmed that the loop only went through one iteration. Then I changed ssh to echo, and the loop iterated through all the hosts. Finally, I figured that ssh was slurping up stdin for some reason, causing the loop to end, and fixed the problem with
while read host; do ssh -n -i id $host command; done < hosts
No comments:
Post a Comment