Reputation: 594
I try to connect to an sftp server using ssh2 but it seems that php get stuck in a loop. Error reporting is on.
my code:
$connection = ssh2_connect('my-server.url', 22);
var_dump($connection);
if (ssh2_auth_password($connection, 'username', 'password'))
{
echo "Authentication success";
if( ssh2_scp_recv($connection, "/throw_me_an_error/", "/somewhere/" ) )
{
echo "file recived";
}
else
{
echo "error";
}
}
else
{
echo "Authentication failure";
}
generate this output:
resource(7) of type (SSH2 Session)
Authentication success
But as soon as the script tries to run ssh2_scp_recv it got stucked and runs forever without any failure. I tried it with existing and with non existing files. Every time the same result - the script runs in a loop.
It is not only ssh2_scp_recv even if i try ssh2_exec or some other method whichs need to write or read on the server, it will get stucked.
Whats going on here?
Thanks!
Upvotes: 0
Views: 1160
Reputation: 286
You might have more luck with phpseclib, a pure PHP SSH implementation.
Upvotes: 3