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

This gives the following error message:

Warning: Identity file ~/.ssh/myfile.pem not accessible: No such file or directory.'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

Then the command appears to work...

building file list ... 
1 file to consider
       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 – Richard Nov 19 '12 at 14:54
--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 (see with ls -l)

share|improve this answer

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

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.