Script for login to servers with user name and password and execute commands

I am having the 15 servers which need to do the monitoring
Hi I need a shell script, By which i can log in to multiple servers and execute the commands.. I need to specify the username and password in the scripts.

Please help me to write the script so that it can login with username and password and execute the commands and generate the report.

It would be greate if anyone give me the sample script so that I can modify as per my requirements

Thanks in Advance

Regards
Nandan

How do you connect? ssh, telnet, or ?

ssh.

I need to specify the password in the script itself.

You cannot do that. You need to create ssh keys, which is VERY EASY to do.

ssh-keygen: password-less SSH login

Then you can do something like this:

for i in server1 server2 server3
do
  ssh $i 'command to do something on each server goes here'
done

Thanks for the reply. But I do not want to create the ssh key.

I need to pass the password in the script itself.

ssh, and any other sane login system, is designed to prevent you from injecting plaintext passwords. "interactive password authentication" means "password typed by a human being in realtime authentication" and nothing else will do. It reads from a terminal to make sure it's getting human input and not scripted input.

It's a subtle hint, written in mile-high flashing neon letters, that scripting passwords is an extremely bad idea. It's insecure. That's why they made it so hard to do.

Fortunately ssh has the simple, easy, and convenient ssh-keys feature built into it for you to use. Just have the right files in the right places and it will work natively.