AWS Ec2 - Scp File Transfer Permission Denied
<p>I have followed the documentation provided to be able to transfer local files to a directory found within the ec2 instance, but I keep getting a <code>Permission denied</code> with the path and file in my ec2 instance prepended to the error.</p>

<p>This shouldn't be an issue with credentials, because I <code>ssh</code> with the same commands without any issue. What I am curious about is possibly the file and folder permissions within my ec2 instance or locally and if that is preventing the transfer.</p>

<p>Sidenote: Not sure if this matters, but when I <code>ssh</code> with same credentials, I am brought to <code>/home/ec2-user</code> and when I run <code>ls -a</code> I don't see <code>/var/app</code> listed, but can <code>cd</code> into it without any issues and find my app.</p>

<p><strong>Full error message:</strong></p>

<pre><code>scp: /var/app/current/config/pk-cfappkey.pem: Permission denied
</code></pre>

<p><strong>Here is my scp command:</strong></p>

<pre><code>scp -vvv -i /Users/user/.ssh/app-key-pair /Users/user/Desktop/Projects/node/project/config/pk-cfappkey.pem ec2-user@ec2-[id].compute-1.amazonaws.com:/var/app/current/config
</code></pre>

<p><strong>Here are my folder and file permissions</strong></p>

<p><strong>Ec2 Instance folder path:</strong></p>

<pre><code>/var/app/current/config
drwxr-xr-x  2 nodejs nodejs 4096 Oct  9 14:35 config
</code></pre>

<p>local file (pk-cfappkey.pem):</p>

<pre><code>-rw-r--r--@ 1 user  staff  1706 Sep 24 15:09 pk-cfappkey.pem
</code></pre>

<p>Detailed error message (summarized):</p>

<pre><code>debug1: Connecting to ec2-[id].compute-1.amazonaws.com [id] port 22.
debug1: Connection established.
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug1: Sending command: scp -v -t /var/app/current/config
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Sending file modes: C0644 1706 pk-cfappkey.pem
debug2: channel 0: rcvd ext data 45
Sink: C0644 1706 pk-cfappkey.pem
debug2: channel 0: written 45 to efd 8
scp: /var/app/current/config/pk-cfappkey.pem: Permission denied
debug2: channel 0: read&lt;=0 rfd 6 len 0
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open -&gt; drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain -&gt; closed
</code></pre>