Skip to content

SFTP Get - Error #17

@enriquemanuel

Description

@enriquemanuel

When doing an SFTP GET the variable status is not defined.
in vendor/sinner/phpseclib-bundle/lib/Sinner/Phpseclib/Net/SFTP.php at line 1545

        // check the status from the NET_SFTP_STATUS case in the above switch after the file has been closed
        if ($status != NET_SFTP_STATUS_OK) {
            return false;
        }

After looking at the function, the $status is never defined.

I would assume that you want to see if the file has been closed or completed right?

If you remove this line, you are omitting the check from the function, but actually allows to pass it correctly after doing the sftp->get()

This would work correctly removing the status check, but I'm working on getting it fixed.

        $serverip='serverip';
        $pathtofile="/path/to/file/file.txt";

        //loading keyfile path
        $pathkey = $this->get('kernel')->locateResource("@EnriqueManuelOpsmartBundle/Resources/config/id_rsa_key");

        //connecting
        $sftp = new Net_SFTP($serverip);
        $key = new Crypt_RSA();
        $key->loadKey(file_get_contents($pathkey));
        $sftp->login('authorizeduser',$key);

        // sftp get to download the file
        $sftp->get($pathtofile,'localfile.txt');
        //disconnect
        $sftp->_disconnect(0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions