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

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

ssh2_scp_send() 函数挂在 php 中。这是代码:

$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;

当我运行它时,它输出"successful connection","uploading file"然后挂起。知道如何解决这个问题吗?

我也尝试过使用 ssh2_scp_recv 下载,但它也挂起,本地文件被创建为 0 字节文件。

我猜服务器安装了监狱 shell。那时 SCP 无法工作,但 SFTP 可以。

最近,我使用 sftp 发送文件,linux 到 windows,ssh2_scp_send 不起作用,我使用

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

然后工作