scp without password between two servers

Hello Folks,

I have two linux server accounts server1 and server2

From the terminal if I say this command,

scp /source/folder/from/server1/unix.txt user@server2.com:/destination/folder/

Then it prompts for the password

user@server2.com's password:

I enter my password and then it starts copying.

But, I would like to do this using bash script because of the size of the files. I searched online before posting and came across using

ssh-keygen

. This one will not serve the purpose because I don't have admin rights to copy the .pub files on to other servers.

Any pointers on how to pass the password to a bash script that can be submitted to the server for execution will be greatly appreciated.

Why do you need admin rights to copy the .pub file? You can scp the .pub file to other server & append it to .ssh/authorized_keys using password for this first time.