ssh login

Hi,

I am trying to login Server2 from server1 in a shell script and need to perfrom few commands,

Below is the command i used to login to server2 from server1

ssh -l username server2

However everytime it executes it asking for password.

How do write a script in such way it takes the password from the script itself rather than from input terminal.

Thanks in advance.

You don't. You install ssh public keys on server2 for the user that does the ssh command.

see:
ssh-keygen: password-less SSH login