Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

I tried mget * but it only downloads files not folders. Is there a "download all" option?

share|improve this question

marked as duplicate by techie007, Dave Rook, Tog, Dave M, Scott Apr 8 '13 at 16:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers

To recursively retrieve directories, you need to use the get -r directive. From the manpage of SFTP(1):


     get [-Ppr] remote-path [local-path]
             Retrieve the remote-path and store it on the local machine.  If the local path name is not specified, it is given the same name it has on the remote machine.  remote-path may
             contain glob(3) characters and may match multiple files.  If it does and local-path is specified, then local-path must specify a directory.
             If either the -P or -p flag is specified, then full file permissions and access times are copied too.
             If the -r flag is specified then directories will be copied recursively.  Note that sftp does not follow symbolic links when performing recursive transfers.

If this is meant to be run from a scheduled job, you need to add those commands to a batch file and use the -b option.

share|improve this answer
add comment

Perhaps the best way is to use wget or curl. Both are available in the CentOS repositories. Both are swiss army knife programs, you'd need to read the manual pages and see which one feels more natural.

share|improve this answer
add comment

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