User:Woozle/PHP/ssh2

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< User:Woozle
Revision as of 15:51, 7 December 2017 by Woozle (talk | contribs) (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_...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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?