title: Cannot SCP from Linux EC2 Instance to Local Machine
body: <p>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.</p>
  
  <p>I can SSH from my Linux machine into my instance (that's how I connect to it), and can even SCP into it by doing<code>scp -i my-key-pair.pem SampleFile.txt ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:~</code>. According to Amazon's instructions at <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html" rel="nofollow noreferrer">this</a> 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:</p>
  
  <pre><code>scp -i my-key-pair.pem 
  ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:~/SampleFile.txt 
  ~/SampleFile2.txt
  </code></pre>
  
  <p>I've googled around, and have even read some similar questions on here including <a href="https://stackoverflow.com/questions/21861385/how-to-download-a-file-from-ec2-instance-to-local-computer">this</a> 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.</p>
  
  <p>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.</p>
  
  <p>By the way, I'm seeing the generic "Permission denied (public key)" error.</p>