User:Woozle/PHP/ssh2
Jump to navigation
Jump to search
This works:
ssh root@waldorf.local
...but this does not:
echo "Creating session...\n";
$session = ssh2_connect('waldorf.local', 22);
echo "Authorizing...\n";
ssh2_auth_pubkey_file($session, 'root', '/root/.ssh/id_rsa.pub','/root/.ssh/id_rsa');
echo "Getting sftp subsystem...\n";
$sftp = ssh2_sftp($session);
echo "Opening...\n";
//$r = fopen("ssh2.sftp://$session/tmp/temp.txt",'r');
$r = fopen("ssh2.sftp://$sftp/tmp/temp.txt",'r');
echo "Done.\n";
After "Opening...", I get "PHP Warning: fopen(ssh2.sftp://Resource id #5/tmp/temp.txt): failed to open stream: operation failed in /var/www/apps/real/fileferret/test.php on line 11"
I think I need to know more about what the actual problem is, but the internet has been unhelpful. Diagnostics, anyone?
Notes
I used these instructions to install ssh2 support from PECL. It seemed to be happy... but I haven't been able to connect to anything. (Then again, I didn't try password auth.)