Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From my DEV server I'd like to copy files from my stage server to my prod server. I already have SSH keys setup between my DEV server and my stage server. But I haven't had any success trying to copy from STAGE to PROD when I'm on my DEV server.

For example, it works right now to tail a log file on my prod server if I run these commands from DEV:

ssh -T my-user@my-stage-ip << TAIL_SCRIPT
ssh -i my-key.pem -o 'StrictHostKeyChecking=no' my-user@my-prod-ip tail -f /var/www/mysite.com/logs/access.log

These are some of the commands I've tried to do without any success.

ssh -T my-user@my-stage-ip << COPY_SCRIPT
scp -i my-key.pem -o 'StrictHostKeyChecking=no' my-user@my-stage-ip:/my/file/path.txt my-user@my-prod-ip:/my/file/path.txt

The error is:

scp: /my/file/path.txt: Permission denied

I also tried:

scp -i my-key.pem -o 'StrictHostKeyChecking=no' my-user@my-stage-ip:/my/file/path.txt my-user@my-prod-ip:/my/file/path.txt

This one also has an error:

Permission denied (publickey).
lost connection
Connection to my-stage-ip closed.

Can someone help me out? This is really frustrating.

share|improve this question
up vote 2 down vote accepted

Check the folder permissions on both sides in regards to the user you are utilizing. It may be as simple as you not having Read permissions on the sending side, or not having write permissions on the receiving side.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.