I'm trying to upload a file from my php server to some other server (my workplace is quite lame enough to block ssh traffic)
Anyway, here's what I'm trying to do: (at: /public_html/manage.php
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib/phpseclib');
include('Net/SSH2.php');
include('Net/SFTP.php');
$ssh = new Net_SSH2('SomeServer',22); //starting the ssh connection to localhost
if (!$ssh->login('root', '12345')) { //if you can't log on...
exit('ssh Login Failed');
}
$sftp = new Net_SFTP('SomeServer',22);
if (!$sftp->login('root', '12345')) { //if you can't log on...
exit('sftp Login Failed');
}
echo $sftp->pwd();
$output = $sftp->put('/root/1_yum_stuff.sh', '1_yum_stuff.txt');
echo $output;
$output = $ssh->exec('ls -a');
//$output = $ssh->exec('./1_yum_stuff.sh & 1>1.txt');
echo $output;
$output = $ssh->exec('pwd');
echo $output;
echo("3rd try!");
?>
The thing is, the file "1_yum_stuff.txt" is located at /public_html/ folder on my php server, and sftp just can't move the file.
Anyway, is this the right way to use sftp module of phpseclib? (e.g. put?)
Thanks:) !