I want a file to be uploaded daily to remote server using automated ftp command. Can someone please help me on this below command to check whether it's right or wrong?

curl -Tu username:password /path/to/dir/*(om[1]) sftp://sftp.example.com/remote/dir


  • username:password is my own username and password.

  • /path/to/dir/*(om[1]): to get the latest(updated) file from my local dir

  • sftp://sftp.example.com/remote/dir: secure file transfer

  • 3
    Do you get any errors when you run this, what have you done to get the answer so that you know first if it is right or wrong? – vgoff Nov 21 '12 at 1:42

Why not rsync instead? You may have to install it (use your package manager), but it's made for this kind of thing.

RSYNC_PASSWORD='password' rsync -rtv /path/to/dir/ username@sftp.example.com:remote/dir

-r will recursively rsync, -t preserves time stamps so existing files aren't re-uploaded (effectively), and -v is verbose.

If you create and copy your ssh public key, you won't need to do the RSYNC_PASSWORD='password' part.

If you don't have a public/private key combination, run:



ssh-copy-key-id username@sftp.example.com

This assumes your remote server supports connecting and updating the $HOME/.ssh/authorized_keys file; otherwise, you'll have to manually upload the authorized_keys file with your public key.

This assumes you're running a recent version of linux. Unix systems like Mac OS don't have the ssh-copy-key-id. Here's some more information on generating and installing your public key on a remote host:


  • 2
    Your point is irrelevant, as OP uses a curl command. – laebshade Sep 12 '17 at 19:51

Your command line has a problem that you can check on the man page. Basically you need to separate the -T <file to be uploaded> from the -u <user:password>. In the end your command line should look more like:

curl -T /path/to/dir/*(om[1]) -u username:password sftp://sftp.example.com/remote/dir

I am not sure about the actual meaning of the regular expression you mention *(om[1]), though.

Finally, the question is about FTP while the command line example is about SFTP, but this shouldn't change the solution I am proposing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.