I have a list of servers in a file I'll call "boxes."
I'm running the following:
bastion:~ # while read i j; do ssh -n $i 'echo $(hostname)'; done < boxes
When I run this, I should be getting the host name of every box I'm supposedly SSHing into right? But what I'm getting is my hostname "bastion" over and over as if the command is not SSHing to any box.
Any idea why that might be or what I'm doing wrong here?
Thanks.
EDIT: I couldn't get SSH to work for this task. In the end I swapped the ssh for ansible -m shell.