0

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 myuser@xxx.xxx.xxx.xxx:/home/myuser/file.txt

scp /Users/me/Desktop/file.txt myuser@xxx.xxx.xxx.xxx:/home/myuser/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 !

Chris
  • 353
  • 1
  • 4
  • 10

3 Answers3

2

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

So...

scp /path/to/textfile.txt myuser@XXX.XXX.XXX.XXX:/path/to/where/you/want/it/
Driftpeasant
  • 3,217
  • 2
  • 22
  • 28
0

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
Liu Ce
  • 1
0

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

or

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.

pwd

... 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.

Sencer H.
  • 562
  • 1
  • 8
  • 17