Difference between revisions of "User:Woozle/PHP/ssh2"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(Created page with "This works: <syntaxhighlight lang=bash>ssh root@waldorf.local</syntaxhighlight> ...but this does not: <syntaxhighlight lang=php> echo "Creating session...\n"; $session = ssh2_...")
 
 
Line 17: Line 17:
  
 
I think I need to know more about what the actual problem is, but the internet has been unhelpful. Diagnostics, anyone?
 
I think I need to know more about what the actual problem is, but the internet has been unhelpful. Diagnostics, anyone?
 +
==Notes==
 +
I used [https://medium.com/php-7-tutorial/solution-how-to-compile-php7-with-ssh2-f23de4e9c319 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.)

Latest revision as of 00:20, 8 December 2017

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.)