I have machines stored in host.txt file. I need to read each line from file and do the ssh for it and run the linux command "cat /etc/redhat-release". Store the output along with machine name in the output file. Not sure if exit is also required after running ssh command.
script:
#!/bin/bash
while read line do
sshpass -p 'abc123' ssh -o StrictHostKeyChecking=no ${line}
echo `cat /etc/redhat-release` >> logfile.txt
done < host.txt
Above one is not working. Please help. Thanks in advance.