I'm attempting to copy a file between two remote servers via PHP using PHPSecLib.
SSH Keys exist between domain.tld and domain2.tld, and locally performing this SCP from domain.tld works fine.
Trimmed down version of my code:
echo "Copying file... ";
$ssh = new Net_SSH2('domain.tld');
$ssh->enableQuietMode();
$ssh->login('user','pass');
$ssh->exec("scp /home/file.tar.gz root@domain2.tld:/home/file.tar.gz");
if($ssh->getExitStatus())
exit("Failed at line: ".__LINE__);
echo "Done!
";
In the example above, the script would finish after 5 seconds, echoing "Done!" at the end, however the copy has not completed and is still running for approx another 2 minutes.
Unfortuantely, I wish to remotely do things with the file that is being copied in this manner, thus waiting for it to complete is necessary.
I've investigated using PHPSecLib Net_SCP as well, unfortunately this cannot perform a remote -> remote copy, and I need to avoid using the local server as an intermediary for the copy process (Due to distance/bandwidth constraints).
I've attempted to re-write the above using $ssh->read() and $ssh->write(), however with limited understanding of how these procedures are supposed to work, I had no success.
Is anybody able to shine some light on this issue for me?