0

The instance is launched and I can connect perfectly from my computer. However when I am trying to upload a file to ec2 using the following command:

scp -r -i key.pem path/file ec2-54-195-205-200.eu-west-1.compute.amazonaws.com:/media/ephemeral0/

I have always the following error: Permission denied (publickey). lost connection

user3333539
  • 595
  • 1
  • 4
  • 5

1 Answers1

1

The username seems to be missing in your scp command. Try adding it before the remote host, separated by a @. For example, with username admin:

scp -r -i key.pem path/file admin@ec2-54-195-205-200.eu-west-1.compute.amazonaws.com:/media/ephemeral0/

The default username in EC2 varies depending on the OS. See this answer for some hints.

Community
  • 1
  • 1
David Levesque
  • 22,181
  • 8
  • 67
  • 82