简体   繁体   中英

Transfer a file via SCP from a web page

I want to provide users the option to upload a file using a Web Page. The remote server accepts file via SCP. This files are normally ISO files (> 2GB)

This is the flow:

File ----> Web page(PHP/JS) --- Apache
  |
  |
 scp
  |
  |
  v
SCP Remote server

Is it possible to do this via a Web page? Normally user would start SCP client and start transfer, but the purpose of this page is to establish direct communication between user and server, and my Web application just to enable this transparently (Passing username/password and scp parameters). I found this function in PHP:

http://php.net/manual/en/function.ssh2-scp-send.php

Since PHP is server side it looks for a local file in Apache web server. I can try a 2 hop solution, but since the files are large, this will double the time of the transfer. Any Client side library that is recommended (HTTP to SCP) ?

Similar: JavaScript File Transfer SSH

Since you don't want the users to access the remote server directly, it does need to be done in two steps.

To avoid locking a web server process for such a long transfer through SCP once the initial transfer is done, it may be a good idea to just dump the file in a folder that is monitored by a small script (daemon) on the web server which would transfer the files once it sees them. When the upload to the web server is complete, you can simply let the user know that their file will be ready in about X amount of time.

Because of the size you wish to allow, you should be extra careful to properly authenticate your users as it will be very easy to abuse your system with such a loose configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM