Help with credentials when using Grep across multiple servers

Hello all,

I need some help with a script I have been working on. I was wanting to know if it is possible to add authentication to it for each server it runs across? The credentials are all the same on each server.

This is what I am using so far and it seems to work. I am trying to avoid typing my password each time it trys to grep each server. Not a big deal either way but it would be nice.

#/bin/bash
echo \ "Log Fetcher"
echo \ "ENTER Value"
read text

for server in [ server1 server2 server3 server4 server5 server6 ]; do echo $server; ssh $server cat /var/opt/blah/blah.log | grep $text;done > /home/blah/blah/blah.log

Please use code tags as required by forum rules!

Putting clear text authentication info into a script/file is unsafe and highly discouraged in these forums. As you are deploying ssh anyhow, consider its key pair authentication instead.

Use ssh-copy-id.

And then you can if you wish use a for loop script to run it against each server in a list. Once you will have to enter your password as you authenticate accross them all. After that you will never have to enter your password for secure login again to any of those servers. Had to do this for 30 some systems. The great thing about key pairs is that attackers don't even bother guessing RSA keys.

ssh-copy-id should work without any issues .