Reputation: 31
I am using the following code from the phpseclib library to login to remote server (Remote server uses: SFTP - SSH File Transfer Protocol):
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('phpseclib/Net/SFTP.php');
$sftp = new Net_SFTP('200.160.163.10');
if (!$sftp->login('username', 'password')) {
exit('Login Failed');
}
?>
After running the above code I get the following message:
Notice: Error reading channel data in /home/comdinhe/public_html/phpseclib/Net/SSH2.php on line 3480
Notice: Connection closed prematurely in /home/comdinhe/public_html/phpseclib/Net/SSH2.php on line 3500
Login Failed
Does anyone know what might be happening?
Log: http://pastebin.com/j9M7tZAM
Upvotes: 1
Views: 2329
Reputation: 528
I think the get method is for Net_SFTP.
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('phpseclib/Net/SFTP.php');
$sftp = new Net_SFTP('200.160.585.10');
if (!$sftp->login('username', 'password')) {
exit('Login Failed');
}
echo $sftp->pwd() . "\r\n";
$sftp->get(
'/sianbima/cbfundo/cbfundo_00000_20160808_171429.txt',
'/home/comdinhe/public_html/testeArquivo.txt'
);
?>
Or you can try execute the rsync command in the ssh.
$ssh->exec('rsync -avz /sianbima/cbfundo/cbfundo_00000_20160808_171429.txt /home/comdinhe/public_html');
Upvotes: 1