I have 2 servers on Amazon AWS. I need to pass a file from A to B.
Both servers have pem keys (different).
I put the pem file of B on A (Is that correct?)
Then tried to do from A:scp -i /tmp/B.pem backup.sql.gz ubuntu@ec2-XX-XX-XXX-XX.eu-central-1.compute.amazonaws.com:bckup.sql.gz
I get an error:
Permission denied (publickey).
lost connectionWhats the problem?
BTW – I opened port 22 on both
Answer
First make sure PEM key permission is correct and not open.
chmod 400 /tmp/B.pem
scp -r -i /tmp/B.pem backup.sql.gz
ubuntu@ec2-XX-XX-XXX-XX.eu-central-1.compute.amazonaws.com:/home/ubuntu/
This will copy the GZIP file on home directory of ubuntu user.
Attribution
Source : Link , Question Author : Noam B. , Answer Author : Azfar Ullah Khan