Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

It's driving me nuts! I just want to transfer one simple file from laptop to server.

I'm using ubuntu on both machines.

So I have:

-rwxr-xr-x 1 sandro    414622 2011-10-14 23:42 sandrophoto-html.tar.gz

And I'm sending it using:

sudo scp -P XXXX sandrophoto-html.tar.gz usern@server.local:/media/xx/xx/xx

And I get: scp: /media/xx/xx/xx/sandrophoto-html.tar.gz: Permission denied

p.s. I might be doing this other way around - I want to send file tar.gz that is located on my desktop, to remote server into the folder /media/yadayda

share|improve this question
up vote 45 down vote accepted

You have things in the right order from what I understand, the general way an scp is done is:

scp sourceuser@sourcehost:/path/to/source/file destinationuser@destinationhost:/path/to/destination/

Judging by your question, you have a local file you want to send to the destination server. So you have the right syntax which is good!

If you're getting permission denied, then you're not using the correct username or something's amiss with the authentication. Most likely, it's because the sudo command only works locally, for starters, so it won't give you root on the remote box, so that's probably the problem. Make sure that the user you are logging in as on the remote server has write permissions to the location you're trying to write to.

If the problem is the destinationuser doesn't have access to that location without sudo, move the file to the destinationuser's home folder then sudo mv the file from the shell on the other server to put it in the right location.

share|improve this answer
thank you Anna :) sending it to home folder worked. – Sandro Dzneladze Oct 15 '11 at 9:25
Thank you, I had to add write permission to destination directory – PiKey Aug 26 '15 at 18:50

Hi had this same permission error problem solved it this way

Make sure the directory you are copying to on is owned by the user username

chown username downloads

On your local machine then do

sudo scp username@


share|improve this answer

Permisssion Denied means you are not the root of the server. You just hold an account there. So in that case you need to do this:

sudo scp -r /path2yourFolder/ username@server_Ip:/home/username

This will copy to your home directory on server.

This will also work:

scp -r /path2yourFolder/ username@server_Ip:~/
share|improve this answer

I had a similar problem, it happened because ssh takes -p xxxx for specifying the port while scp takes -P xxxx to specify the port. Minor inconsistency, so easy to miss :(

share|improve this answer
thanks, this cost me about 2h :D – user643011 Feb 9 '15 at 10:57

This error occurred for me when the file already existed in the target location and the existing file had read-only permissions (preventing the file from being overwritten). In my case, I just logged in and deleted the existing file and that corrected the problem.

share|improve this answer

Had the same problem. I found out that the directory containing my source file did not have enough permission. So I just changed the mode recursively using:chmod -R 771 directory_path on the source machine.

share|improve this answer

protected by Community Mar 11 at 22:57

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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