The SCP can not switch from the Linux EC2 instance to the local machine


I'm trying to SCP a file from my Amazon EC2 instance into my Linux machine. I've done quite a bit of reading and nothing seems to work.

I can SSH from my Linux machine into my instance (that's how I connect to it), and can even SCP into it by doingscp -i my-key-pair.pem SampleFile.txt [email protected]:~. According to Amazon's instructions at this link, in order to SCP from the instance to my machine I need only to "simply reverse the order of the host parameters." In other words, this:

scp -i my-key-pair.pem
[email protected]:~/SampleFile.txt

I've googled around, and have even read some similar questions on here including this one, but I've had no luck. I'm not sure what the problem is. The other day I managed to SCP across instances (i.e., from one EC2 instance to another) without a problem -- which at least supposedly requires a bit more tinkering.

Another bit that is troubling me as well, is the fact that the command to SCP from the instance to the local machine includes the private key (my-key-pair.pem on the code block above), and I've looked for a .pem file on the instance and have not found one. Am I missing something? Thanks in advance.

By the way, I'm seeing the generic "Permission denied (public key)" error.

I found out what the problem was. I was running the command from the instance instead of my local machine, which is somewhat odd given that when you SCP from an instance to another you run the SCP command from the instance you're copying from, but oh well.