I am trying to automate a file copy task from one host to another. First of all, I create a private-public key pair from my own machine (without passphrase), and I upload the public key to let's say the receiver host B, at ~/.ssh/authorized_keys
using the password. After that, I test that I can access B through the ssh, and it works fine. Then, I copy my private key to host A which is the sender. I try to copy a file using scp scp -i ~/.ssh/my_private_key test.png [email protected]:/root/test.png
, but it asks me for a passphrase, although I am sure I did not set any passphrase. I also tried using a key with a passphrase, and it did not accept it.
When I create a private-public key directly in A, it works. Does this has to do with moving the private key from one host to another? Any workaround for this? (In my case, I will using private keys from end-users, so they will definitely not be created locally).
.ssh
dir on both machines, too. If they are too permissive, e.g. private keys are accessible by group/others in the filesystem, the keys will not be used.