2

I want to download directory from sftp to a server.I am able to login to sftp using

  sftp rob2056@storagename

and then can get individual files using :

   get *.txt /remotedir

But I want to download multiple directories from sftp to remote,which I am not able to do:

    get -r * /remotedir

(does not work)

8
  • Does not work in what sense? Any error message(s)?
    – KM.
    Commented Jan 23, 2015 at 19:16
  • it says invalid flag
    – Ron
    Commented Jan 23, 2015 at 19:17
  • Try get -r /remotedir instead?
    – KM.
    Commented Jan 23, 2015 at 19:21
  • Thats what it says invalid flag,again
    – Ron
    Commented Jan 23, 2015 at 19:26
  • Mm. Try with sftp -r rob2056@storagename ... ? I'm starting to suspect your version of sftp may not support -r. In which case you would update it or use another tool like scp.
    – KM.
    Commented Jan 23, 2015 at 19:30

4 Answers 4

1

Is the local directory remote already created before issuing the command get -r * /remotedir ?

I tried this:

  • Created a directory on the local machine remotedir inside which I had to transfer all the folders.

  • Issued the command get -r * remotedir without the slash and it worked. I've no idea why the / matters though.

0

Use mget instead of get when using metacharacters like ' and ?. You might think of the m as meaning multiple.

1
  • mget is for multiple files when i am in a directory.I want to download multiple directories.So it does not work in this case.its basically same as get *
    – Ron
    Commented Jan 23, 2015 at 19:45
0
mirror -c TestTransfer/ /remotedir

This command can be used to copy the whole directory.

1
  • Which SFTP client do you use?
    – hagello
    Commented Jul 16, 2015 at 6:54
0

Maybe your SFTP client does not know how to mirror directories.

Though there are other SFTP clients. You might want to install a different one or a newer version of your client. The SFTP client in the RedHat package openssh-clients-6.4, for example, knows the -r option.

This is how I got the version of my SFTP client:

rpm -qf /usr/bin/sftp

Apart from that, you might want to do a web search for sftp client.

You must log in to answer this question.

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