For that, I created a public-private key pair using ssh-keygen -t rsa in machine A. Then I sent the id_rsa.pub file to machine B and I added that to the authorized_keys file there.

It was working fine while sending from machine A to B, I was not being prompted for the password.

While doing some other experiments with this I accidently deleted the authorized_keys file. Now again when I started the above procedure its not working. How to recover that? I am also interested to know is it possible to send files both ways round without being prompted for password?

1 Answer
1

Check the permissions, the recommended permissions are read/write
for the user, and not accessible by others.

Check that you don't
have extra line breaks in the file and that the key in it actually
matches the (correct) public key of A.

Note that you don't need to recreate the key pair.

If you want to have public key access from B to A, just replicate the process (create keys in B, move pub to A and add to authorized_keys in there).

Note that public key authorization is the way to identify client to server. In order to be able to use B as a client, you need to have sshd running in A.

Of course you can use scp from A also to transfer files from the server B to A without a password, if that was what you ment by "send files both way round without being prompted for password": scp serverB:filename .