0

I have a PHP web-app that lists files on a server using ssh. I want the browser/user to be able to download those files. The Apache ID www-data does not have access to the files/folders. The PHP code will use ssh to ls the files for displaying on the browser.

Now I am trying to figure out how to make it so the browser/user can download the files.

I know one way is to have PHP scp the file to a "local" folder that www-data can read so that it can then let the browser/user download the file. I want to avoid this -- I do not want any intermediary transfers.

So I'm wondering if there is another way. I had one idea of creating a file transfer stream using scp where the target is into a PHP something that then sends to the browser. But I don't know if this is possible or if it even makes sense.

user goes to site via web browser -> www-data makes an ssh call to server and lss files -> user clicks on a file to download -> Apache/PHP does something using ssh/scp so that it goes back to the user's browser for download

IMTheNachoMan
  • 4,591
  • 3
  • 30
  • 64
  • You cannot modify permissions? – Nic3500 Dec 11 '18 at 05:16
  • Found this: https://stackoverflow.com/questions/35920490/how-can-i-fetch-a-remote-file-in-php-over-ssh-and-return-file-directly-to-the-br and/or this https://stackoverflow.com/questions/6914912/streaming-a-large-file-using-php – Nic3500 Dec 11 '18 at 05:20
  • Can't change permissions. And those two links are great. Thank you so much! My searches didn't yield them. – IMTheNachoMan Dec 11 '18 at 15:36

0 Answers0