0

I want to get the file structure (listing only) on an sFTP server. I'm currently using the cURL bash command with multiple calls.

In order to avoid multiple connections, I'd like to use openssh multiplexing. I followed the instructions on https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing though using cURL to get the file list this does not work.

On the other hand, "standard" ssh connection do use the multiplexing.

Questions:

  1. is there a way to use multiplexing with cURL?
  2. if not, is there another linux command line tool to get the file listing?
ezdazuzena
  • 6,120
  • 6
  • 41
  • 71

1 Answers1

2
  1. Not for SFTP, no. The SSH protocol (and libssh2 that curl is using) allow for multiplexing perfectly fine but curl itself has not been adapted to actually take advantage of this, so doing multiple requests to the same host will still use separate connections.

  2. The sftp command by OpenSSH used like: echo ls | sftp example.com:dir/

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
  • do you have any link/comment/hint why cURL does not work with multiplexing? It's ssh in the end, right? And with respect to 2: you solution lists the specified folder, but not the full file structure, i.e. all sub folders and files – ezdazuzena Aug 08 '16 at 14:33
  • 1
    Easy: nobody implemented SSH multiplexing for curl so it doesn't work. Sure the SSH2 and SFTP protocols allow it and so does libssh2 that curl uses, but curl needs to take advantage of it. I don't think SFTP the protocol nor sftp the tool have a recursive ls feature. – Daniel Stenberg Aug 08 '16 at 15:54