Help - Search - Members - Calendar
Full Version: Using Ssh W/ Password In Shell Scripts
Linuxhelp > Support > Technical Support
I have written a shell script that simply tests using SSH to log in to multiple computers sequentially. The computer names are input from a file. SSH is using password authentication, which means that when the script runs, it asks for the password before logging in to every node in the file. So far the script is as follows:

for eachhost in `cat $1`
echo "Testing $eachhost"
ssh root@$eachhost cd /home

It's a simple script and all I would like to know is how to put passwords in the script so that I don't have to manually enter them for every computer.

Alternatively, if you know of a way to include the passwords in the input file (that has the computer names, so that the file would then contain name/password pairs) and to use them to login in the script, that would be just as good if not better.

Thanks in advance for your help!
you would use private and public key files to eliminate the use of having to use a password to login.....doing this
allows for automated logins....but doesnt ELIMINATE the use of passwords....
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.