Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to rsync a file over to my EC2 instance:

 rsync -Paz --rsh "ssh -i ~/.ssh/myfile.pem" --rsync-path "sudo rsync" file.pdf ubuntu@ec2-XXX-XX-XX-X.compute-1.amazonaws.com:/home/ubuntu/

This gives the following error message:

Warning: Identity file ~/.ssh/myfile.pem not accessible: No such file or directory.
ubuntu@ec2-XXX-XX-XX-X.compute-1.amazonaws.com's password: 

The pem file is definitely located at the path ~/.ssh/myfile.pem, though: vi ~/.ssh/myfile.pem shows me the file.

If I remove the remote path from the very end of the rsync command:

rsync -Paz --rsh "ssh -i ~/.ssh/myfile.pem" --rsync-path "sudo rsync" file.pdf ubuntu@ec2-XXX-XX-XX-X.compute-1.amazonaws.com

Then the command appears to work...

building file list ... 
1 file to consider
file.pdf
       41985 100%    8.79MB/s    0:00:00 (xfer#1, to-check=0/1)
sent 41795 bytes  received 42 bytes  83674.00 bytes/sec
total size is 41985  speedup is 1.00

...but when I go to the remote server, nothing has actually been transferred.

What am I doing wrong?

share|improve this question
    
I ended up using scp instead, with no problems: scp -i ~/.ssh/myfile.pem file.pdf ubuntu@ec2-XXX-XX-XX-X.compute-1.amazonaws.com:/home/ubuntu/ –  Richard Nov 19 '12 at 14:54
add comment

2 Answers

--rsync-path "sudo rsync"

This makes rsync to run by privileged user (root), so ~/ is path for home directory of root. If you omit this part of code it should work.

PS. scp is working, because you run it using your normal account.

PS2. Removing remote path also work, but this does not send anything through the network, but just copy the file "file.pdf" to file with name ubuntu@ec2-XXX-XX-XX-X.compute-1.amazonaws.com (see with ls -l)

share|improve this answer
add comment

When it's just a couple files, using rsync isn't a big win over scp. But if you are managing a full document tree, it's great because it only sends the diffs. Here's what I always do:

Set up an entry for the remote server in my ~/.ssh/config file

Host easy-short-name
  HostName ec2-XXX-XX-XX-X.compute-1.amazonaws.com
  IdentityFile ~/.ssh/private_key.pem
  User ubuntu

Then you can just use this rsync command without messing with usernames, keyfiles, or long hostnames:

rsync -avrk source-dir easy-short-name:~/destination-dir

This setup also works with scp and has the benefit of allowing me to just use ssh easy-short-name to log in.

share|improve this answer
add comment

Your Answer

 
discard

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.