Home » Questions » Computers [ Ask a new question ]

How do I get an entire directory in sftp?

How do I get an entire directory in sftp?

I'm just learning to use sftp, and I want to copy a directory from the remote computer to my local computer. If I try

Asked by: Guest | Views: 244
Total answers/comments: 5
bert [Entry]

"Use the -r (recursive) flag:

get -r *"
bert [Entry]

"Use lftp:

lftp sftp://user@host

Then, within lftp, cd into the directory you want to copy,
and use the mirror command to recursively download the selected directory,
like this:

mirror

This command accepts options and arguments:

mirror [OPTIONS] [source [target]]

For example, the -R (or --reverse) option
will cause it to upload the local directory tree to the remote directory:

mirror -R

See the lftp(1) man page at the project’s site
or at Debiandotorg for other commands and options."
bert [Entry]

"Try mget instead of get.

Clarification: mget will work if you are inside the directory you want to copy; if you do something like this:

sftp> cd dir_to_get
sftp> mget *

it will get all the files in that directory. However, it will not recursively get the contents of any subdirectories."
"Try mget instead of get.

Clarification: mget will work if you are inside the directory you want to copy; if you do something like this:

sftp> cd dir_to_get
sftp> mget *

it will get all the files in that directory. However, it will not recursively get the contents of any subdirectories."
bert [Entry]

"get -r [directory]

gets [directory] and everything under it, where r stands for recursive. I found this just by typing help from sftp."
bert [Entry]

"As with cp:

scp -rp user@host:/path/to/dir dir

The above will preserve times and modes of the original files and subdirectories. This is especially useful for the retrieval of backups."