scp scripting without asking password

I like to copy a file from one server server1 from path path1 to another server server2 to path path2.

User logging in both the servers are same say user1

I tried to use ssh to generate public/private key pairs and then copy without prompting for password.

These are the steps i followed

  1. Public/private key pairs (identity/identity.pub) are generated in home/user1/.ssh in server1. using the following command
    ssh-keygen -t rsa

  2. identity.pub in server 1 is copied to home/user1/.ssh/authorized_keys in server 2.
    scp .ssh/id_rsa.pub user1@server1:/home/user1/.ssh/authorization_keys/
    (this scp is done by providing the password. i double checked this copy and i can confirm this copy done properly)

  3. Tried the following command in server1
    scp path1/file1 user1@server2:/path2/file2

I believe it should not ask for the password and copy should happen smoothly. But it is still prompting for password. Why is it still asking for password?

And also note that permissions for .ssh directory in both servers are set to 600. Let me know where i went wrong.

Please help me in this issue. I am breaking my head for one day for this. :confused:

Set the permissions for the .ssh directories to 700, not 600. 600 would prevent the owner of the directory from accessing it. Set the perms on the authorize_keys/authorized_keys2 file to 600.

I think that should do it.

I set the permission for .ssh directory to 700 and .ssh/authorized_keys to 600. Still it is not working. I couldnt understand where i went wrong. I retried everything again. Still not working. Please help me

Did you really copy to a file named authorization_keys? It should be authorized_keys

One more thing - if you are using SSH protocol version 2, the file is authorized_keys2 and not authorized_keys. Just check that out, will you?

Thank you blowtorch, dangral very much .. i had a similar issue and i got it resolved by following your steps... thanks alot...