Skip to content

ssh2_scp_send() truncates files, incomplete file saved on remote server #69

@triatic

Description

@triatic

Description

The following code:

<?php
$ssh2 = ssh2_connect('example.com');
ssh2_auth_pubkey_file($ssh2, 'ubuntu', 'pubkey', 'privkey');
$sftp = ssh2_sftp($ssh2);
ssh2_sftp_unlink($sftp, 'myfile');
ssh2_scp_send($ssh2, 'myfile', 'myfile');
$myfile = ssh2_sftp_stat($sftp, 'myfile');
if ($myfile['size'] != filesize('myfile')) echo 'File size mismatch, local: ' . filesize('myfile') . ', remote: ' . $myfile['size'] . "\n";

Resulted in this output:

File size mismatch, local: 3938770, remote: 2310144

But I expected this output instead:

I should get no output as the file sizes on the local and remote servers should match. ssh2_scp_send() is not sending the whole file to the remote server.

PHP Version

PHP 8.1.2

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions