I’m using the phpseclib for secure ssh and ftp access. My site is on a webserver, that connects to a different backup server and displays the files and folders, imagine a frontend for a backup on several different servers.
Now I would like them to be able to download a file, but I can’t think of a better method than temporarily store the file on the front webserver.
I looked at the phpseclib docs and didn’t see a great way to transfer a file from one of the backup servers to the frontend server to a client in a fast efficient way without having to fully copy the file from backup server to frontend server before passing it to the client.
Using cURL you can use one of its callback functions to serve a download to the client simultaneously while the file is being downloaded from the backup server by cURL. cURL will support ssh and sftp. This way, you don’t have to have the frontend fully download the file from the backup before being able to send it to the client.
I have shown a similar example of this using the FTP protocol in this answer: Streaming a file fromFTP and letting user to download it at the same time
Feel free to ask for more help if you have any questions implementing this solution with SSH and your system.