Subject: ssh_tunnel


From: <>
Date: Fri, 12 Nov 2010 13:43:26 -0800

Hello everyone,

I am actually here with a usage question for the libssh2 PHP binding
rather than a devel question, feel free to redirect me.

I am trying to setup a tunneled ssh connection from a PHP script to an ssh

server. It's a two-step connection over a 'security gateway', as firewalls

prevent me from reaching the target server directly.

Using ssh, i would typically do

ssh -NL localhost:localport:desthost:22 &
ssh -p localport localhost

Now, the PHP binding does provide ssh2_tunnel() which takes remote host
and port, but it returns a PHP resource accepting fwrite(), fgets(), etc.
Unless there is something major I am missing, I believe this is of any
use for another ssh connection through it. Or is there a way to start
a libssh2 session on an existing tcp connection using the PHP binding ?

Any help is appreciated.

Immanuel Gregoire
Received on 2010-11-12