简体   繁体   中英

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

ssh2_scp_send() function is hanging in 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.

My guess is that the server has a jail shell installed. At that point SCP wouldn't work but SFTP would.

recently,i use sftp to send file,linux to windows,ssh2_scp_send not work,i solve the problems use

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

then works

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