I have a script that I am trying to run. The purpose of this script is to run single or multiple commands on list of servers. When running it, the script is not able to parse the hosts file and gives an error:
ssh: Could not resolve host name nodename nor servname provided, or not known
while read host;
do
echo server: $host
sshpass -p 'password' ssh -o "StrictHostKeyChecking no" admin@$host 'command'
done < /path/to/hosts.txt
hosts.txt
contains list of IP addresses of the hosts that need to connect in the following format:
server 1
server 2
server 3
I have tried putting the server IPs in ""
and ''
and ;
and ,
, but they all give the same error.
Can someone explain what I am doing wrong here?