views:

519

answers:

3

Hello,

I got access via SSH (root access) to a Machine that's inside a network at my client's office.

I'm programming in my computer a PHP application that needs to integrate to LDAP. The LDAP server is in another server at my client's network and not accesible from outside, however I can perfectly access it via the server I can connect to via SSH.

My question is: IS there anyway I can make a tunnel and setup a port in my computer to get the traffic forwarded to the LDAP server using my SSH connection to one of the computers on the network?

Thanks!!!!

+7  A: 

Yes, ssh has a "-L" option to create a tunnel. That option takes 3 parameters, separated by colons (:). Local listen port, remote host, remote port.

ssh -L 9999:ldapserver:389 user@otherhost

Where 9999 is the local port that the tunnel will be created on. The ldapserver:389 bit tells it where to connect to on the other side.

Then, tell your application to connect to localhost:9999 (or whatever port you choose) and it will be tunneled across.

Adam Batkin
you might also use the -N option, so ssh doesn't become interactive
ammoQ
thanks! I got connection refused although with both optins but this may be another problem
Guillermo
you need to tcp forwarding enabled on the remote ssh server. By default this is often disabled. In sshd_config put:AllowTcpForwarding yes
Gunstick
A: 

I have the same situation as You, Guillermo. Can I ask You, what arguments did You passed to function ldap_connect() in order to connect with no errors? Because I'm always getting error "Can't contact LDAP server...".

The network with LDAP server is accessible from my house by server with address phoenix.lo5.bielsko.pl. The address of LDAP server inside this network is auth.lo5. LDAP server is listening on ports 389 and 636. On my local computer I've edited /etc/hosts, so auth.lo5 is pointing on 127.0.0.1 So, I'm making tunnel by typing:

ssh -L 636:auth.lo5:636 [email protected]

Then, in PHP I connect to my server by:

ldap_connect('ldaps://auth.lo5', 636);

Then, during binding I'm getting above-mentioned error "Can't contact LDAP server...". What should I change in order to get it working?

Hfaua
A: 

I have a similar problem in that I need to tunnel through an intranet http proxy to get to an LDAP server on the outside. I am writing in java and I need to know the syntax for creating the tunnel. Thanks!