Server Fault is a question and answer site for system and network administrators. 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

I am trying to copy a file from my local Mac to my Linux instance running on the Amazon EC2 / AWS Cloud.

I am able to connect to the server via Terminal, but am unable to get my file up to the server.

Here is what I've tried: (yes, I replaced myuser@XXX.XXX.XXX.XXX with the actual server info)

scp /Users/me/Desktop/file.txt myuser@XXX.XXX.XXX.XXX:file.txt

result: Sink: scp: /Users/me/Desktop/file.txt: No such file or directory

scp ~/Users/me/Desktop/file.txt myuser@XXX.XXX.XXX.XXX:file.txt

result: scp: /home/myuser/Users/me/Desktop/file.txt: No such file or directory

So it seems that when I use the ~/Users/ ... it thinks I am trying to copy the file from the server? But when I only use /Users/ ... , it still says it cannot find the file.

Any help would be greatly appreciated.

More Info ...

Here are some additional tries I have made, all with the same result:

scp localhost:/Users/me/Desktop/file.txt

scp /Users/me/Desktop/file.txt

Is there something else I need to do to tell it to grab the file from my desktop machine?

Figured it out ...

Okay, so I was trying to do this while I was already connected to the server. It makes sense to me now, but I was connecting to the server and then trying to move the file.

Thank you for all your help and sorry for the confusion !

share|improve this question
up vote 2 down vote accepted

Generally you have to specify the path on the remote machine.


scp /path/to/textfile.txt myuser@XXX.XXX.XXX.XXX:/path/to/where/you/want/it/
share|improve this answer
I have also tried that, makes no difference - and doesn't really answer the question of why it is saying it can't find the file on the local computer. – Chris Dec 9 '11 at 3:40
provide output of 'stat /path/to/file.txt' – thinice Dec 9 '11 at 3:59
If you're using the wrong syntax, you can get that error message - it's why I suggested it. – Driftpeasant Dec 9 '11 at 4:17
It says that it cannot stat the file... is there something I need to do to tell it to look on my local machine? – Chris Dec 9 '11 at 17:16
Please see edits to the original post. – Chris Dec 9 '11 at 17:21

looks like your default directory on remote server is /Users/me/Desktop, you should create the directory on remote server,like this:

mkdir /Users/me/Desktop

or put the file.txt to a exiting path.

ssh /path/to/file.txt username@hostname.domain:/path/to/target/file.ext
share|improve this answer
No... /Users/me/Desktop is on my local machine. – Chris Dec 9 '11 at 17:14
Please see edits to the original post. – Chris Dec 9 '11 at 17:21

I think you gave defective path to command...

Most absolute path begins with slash "/" which means root directory. It's also applies to remote system. Check this out:

scp /path/to/read/file.txt username@hostname.domain:/file.txt


scp /path/to/read/file.txt username@hostname.domain:/path/to/write/file.txt

And also in your condition, you must check path if you get errors. You can check the path by type command below in your folder that where the file.txt is.


... Anyway, if you think your file is on the right place, you can change directory to where it is and check the pwd result

if you can change your path by command below:

cd /Users/me/Desktop/

and you can list the file you want to send:

ls -la | grep file.txt
-rw-r--r--  1 me me 14320 2011-11-15 09:50 file.txt

there might be user permission issues. Check if you can display inside the file by cat file.txt If you do not have read permission on the file you can't send file to anywhere. First of all you must granted some permissions on that file.

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.