I want to copying multiple files from remote machine using rsync. So I use the following command.

rsync -Pav -e 'ssh -i sshkey' user@remotemachine:/home/user/file1.zip file2.zip file3.zip  .

It shows following error

Unexpected local arg:file2.zip If arg is a remote file/dir, prefix it with a colon (:). rsync error: syntax or usage error (code 1) at main.c(1362) [Receiver=3.1.0]


2 Answers 2


This is pretty old, but the accepted answer is a bit too strict - multiple files are not necessarily a single argument to rsync. From man rsync:

       The  syntax  for  requesting  multiple  files  from a remote host is done by specifying additional remote-host args in the same style as the first, or with the hostname omitted.  For
       instance, all these work:

              rsync -av host:file1 :file2 host:file{3,4} /dest/
              rsync -av host::modname/file{1,2} host::modname/file3 /dest/
              rsync -av host::modname/file1 ::modname/file{3,4}

so OP's command would be

rsync -Pav -e 'ssh -i sshkey' user@remotemachine:/home/user/file1.zip :/home/user/file2.zip :/home/user/file3.zip  .

This is not possible for older versions of rsync, but I think all major distros some with this for several years now.

  • a lot more logical, sad it wasn't there from the start. Nov 30, 2021 at 0:52

All remote files should be one argument for rsync. So, just put all remote files in single quotes:

rsync -Pav -e 'ssh -i sshkey' 'user@remotemachine:/home/user/file1.zip file2.zip file3.zip' .

BTW, you can also do this with a Asterisk (the Asterisk will be resolved by the remote shell then):

rsync -Pav -e 'ssh -i sshkey' 'user@remotemachine:/home/user/*.zip' .
  • 3
    It works Great Because of Alexander The Great
    – SuperKrish
    Sep 9, 2016 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .