Pass root password through script

I have several clients (over 120) connected to my server. I want to push some patch to all the client using a script which copies the file from the server to a specific path on the client and then installs it.

But for installation of the patch, it needs to be done thorough root login on client. Root password for all clients is 123456

How do I pass the password through the script.

can you give some examples, screenshots or desired input/output?

Using this function, I tar the file modules-2.6.20.1.tar on all Clients one by one. But everytime I need to enter the root password(123456) when script connects to clients one by one.
For e.g program is excuted on C1, then it connects to C2, I need to enter the password after which it is copied to C2...similarily for rest of the clients.

findClients
for Client in $Clients; do
echo -n "$Client " >t
ssh root@$Client "tar -xvf /lib/modules/2.6.20.1/modules-2.6.20.1.tar"
2.6.20.1.tar"> h.txt
done

storing your plain text password in a shell script is a very bad idea

Agreed...but manually entering '123456' for 150 time is even more bad idea...Password has been given jst because system needs a password else, no security was required on these clients.

Pl. help

Sudo or ssh with keyless

how about setting SSH keys between the hosts?

Thanks for the reply..but the number of clients is not fixed. Server will ping the client's host name one by one and will install the package on the clients till it reaches the last client. Host name of clients is C1, C2, .......C200 for which a function has already been written which is as follows :

function findClients() {
    local ClientnotReachable=
    echo -n "Finding online Client...: "
    do
    echo "Client No: $Client"
    ping -c 1 -W 1 p$Client >/dev/null 2>&1
    local ret=$?
    if [ $ret = 0 ]; then
      Clients="${Clients}P${Client} "
      echo -n "$Client "
    elif [ $ret = 1 ]; then
      ClientnotReachable="${ClientnotReachable}Client${Client} "
      echo -n ". "
    elif [ $ret = 2 ]; then
      # no entry found in /etc/hosts or from DNS
      ClientnotReachable="${ClientnotReachable}Client${Client} "
      echo -n ". "
    fi
  done
  echo
  if [ ! -z "$ClientnotReachable" ]; then
    echo "Following Client are not reachable: $ClientnotReachable"
  fi
}

findClients
for Client in $Clients; do
echo -n "$Client " >t
ssh root@$Client "tar -xvf /lib/modules/2.6.20.1/modules-2.6.20.1.tar"> h.txt
done

=====================================================
This my entire script...in the first part, server will check for online clients and in the 2nd part, it perform the required action but for every ssh login to a client, it asks for the password.

---------- Post updated 11-12-10 at 01:34 PM ---------- Previous update was 11-11-10 at 04:35 PM ----------

Anyone.....pls...help....