-1

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 connection

Whats the problem?

BTW - I opened port 22 on both

HBruijn
  • 77,029
  • 24
  • 135
  • 201
Noam B.
  • 119
  • 3
  • 7

3 Answers3

1

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.

0

I think you got it wrong.
If you want to pass a file from A to B, you need to put the authentication key from A on B. B authenticates a connection from A.

Hestben
  • 31
  • 7
  • what the OP calls 'pem key' is actually the ssh private key. What he is doing is correct: he copied the private key of B on A and he's is using it to authenticate on A. – Luca Gibelli Mar 27 '18 at 11:26
-4

Perhaps try to see if destination folder have write permissions.

  • 1
    wrong filesystem permissions will not result in errors regarding the public key (except permissions of the .ssh folder of course). – Gerald Schneider Mar 27 '18 at 08:55