简体   繁体   English

ssh2_scp_send()和ssh2_scp_recv()函数在php中不起作用。 为什么?

[英]ssh2_scp_send() and ssh2_scp_recv() functions are not working in php. Why?

ssh2_scp_send() function is hanging in php. ssh2_scp_send()函数挂在php中。 Here's the code: 这是代码:

$debug_line_feed = "\n";
$conn = ssh2_connect($sftp_server, 22);
$return = ssh2_auth_password($conn, $sftp_user_name, $sftp_user_pass);
if ($return===true) echo "successfull connection".$debug_line_feed;

echo "uploading file".$debug_line_feed;
$local_filename = $product_feed_file_with_path;
$remote_filename = 'product_feed.txt';
ssh2_scp_send($conn, $local_filename, $remote_filename);
echo "successful".$debug_line_feed;

When i run it, it outputs "successful connection", "uploading file" then hangs. 当我运行它时,它输出“成功连接”,然后“正在上传文件”挂起。 Any idea how to fix this? 任何想法如何解决这个问题?

I have tried a download as well with ssh2_scp_recv, and it hangs as well, with the local file being created as a 0 byte file. 我也尝试过使用ssh2_scp_recv下载,并且它也挂起,本地文件被创建为0字节文件。

My guess is that the server has a jail shell installed. 我的猜测是服务器已安装了监狱外壳。 At that point SCP wouldn't work but SFTP would. 到那时,SCP无效,但SFTP可以。

recently,i use sftp to send file,linux to windows,ssh2_scp_send not work,i solve the problems use 最近,我使用sftp发送文件,linux到Windows,ssh2_scp_send无法正常工作,我解决了使用问题

$sftp = ssh2_sftp($conn);
 $contents = file_get_contents($localPath);
 $result = file_put_contents("ssh2.sftp://{$sftp}/{$remotePath}", $contents);

then works 然后工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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