dongzhi2014 2015-09-07 06:52
浏览 103

PHPSecLib:在远程服务器上执行scp到另一台远程服务器会提前终止吗?

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?

  • 写回答

2条回答 默认 最新

  • douxiajia6720 2015-09-08 18:22
    关注

    Are you using public key auth? If you're using password auth then you'd need an interactive prompt. Or you could use the sourcefile attribute too.

    I tried it just now using public key auth and it worked just fine.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器