[xdebug-general] Re: Can't get SSH tunnel debug to work

From: Derick Rethans <derick[@]xdebug.org>
Date: Fri, 20 Nov 2015 16:16:25 +0000 (GMT)

On Thu, 19 Nov 2015, Spencer Williams IV wrote:

> Hey there. Thank you very much for helping me with past issues. This time, I
> am using xdebug with ssh tunneling. In previous projects, I've been able make
> such tunneling work and I'm having trouble discovering the issue in this case.
>
> First of all, I read that all that is really required to initiate SSH
> tunneling is to connect to your remote machine via SSH with a command like the
> following:
>
> ssh user[@]remote-machine -R9000:127.0.0.1:9000

What this means is:

ssh to remote-machine, and create an endpoint on port 9000, which gets
forwarded to port 9000 on 127.0.0.1 (as seen from your current machine).

>
> I understand the "remote-machine" to be the one you have your PHP site on,
> which has xdebug installed, and your local machine is the "debug client" where
> you are running an IDE (Eclipse in my case) on which you want it to stop on
> breakpoints. I was not entirely sure if port 9000 was in use before, so I'm
> having Eclipse listen for xdebug requests from the remote-machine on port 9010
> of my local machine.
>
> And so, the remote-machine has the following in its xdebug.ini:
>
> zend_extension=/usr/lib/php/modules/xdebug.so
> xdebug.remote_enable=1
> xdebug.remote_handler=dbgp
> xdebug.remote_mode=req
> xdebug.remote_host=10.0.0.2
> xdebug.remote_port=9010
> xdebug.remote_log=/var/log/php/xdebug.log
>
> 10.0.0.2 is the IP of my local machine, the debug client as I understand it.
> I've also been using the info on this site for guidance:
> http://blog.rabin.io/linux/setup-xdebug-remote-debug-ssh
>
> I confirmed my local machine is listening on port 9010 as well.

If you use an SSH tunnel, then Xdebug needs to connect to the "remote
end" of the tunnel, which should be 127.0.0.1 (from the point of view
of xdebug). Using 10.0.0.2, would not connect to your tunnel.

Additionally, your config says "port 9010" but your tunnel says "listedn
on port 9000" and "forward to localhost on port 9000". You say that
Eclipse listens on port 9001, so that's what you should use.

You should change your Xdebug config to:

> xdebug.remote_host=127.0.0.1
> xdebug.remote_port=9010

And your tunnel command to:

> ssh user[@]remote-machine -R9010:127.0.0.1:9010

> I set the remote_log so I could get more information, but nothing is written
> to that file. I know that the httpd process owner, the apache user in my case,
> needs to be able to write to it, but I went ahead and let everyone write to
> it. The remote-machine has SELinux disabled, so I know that is not the issue.
> Here are the permission from the root all the way to that file:
>
> dr-xr-xr-x. 22 root root 4.0K Nov 18 14:22 /
> drwxr-xr-x. 24 root root 4.0K Nov 6 16:01 /var
> drwxr-xr-x. 13 root root 4.0K Nov 19 11:20 /var/log
> drwxr-xr-x 2 root root 4.0K Nov 19 11:20 /var/log/php
> -rw-r--rw- 1 root root 0 Nov 19 11:20 /var/log/php/xdebug.log

None of those directories allow the writing of xdebug.log though. It's
best to use xdebug.remote_log=/tmp/xdebug.log instead.

> xdebug.log never has anything written to it. I am quite sure Eclipse is
> properly setup to debug with xdebug remotely on this server. I am following
> these instructions rather accurately:
> https://wiki.eclipse.org/Debugging_using_XDebug#Debugging_using_VirtualHosts_.28http:.2F.2FmyProject.local.29,
>
> My local OS is OS X and the remote is a Red Hat flavor of Linux.
>
> Why on God's green earth does this setup not result in anything
> written to the xdebug log, nor any communication between the remote
> and local server via xdebug, as far as I can tell?

I think your permissions are wrong, or perhaps, you're not activating
the debugger. Do you use any of the browser extensions, or something
else?

cheers,
Derick

-- 
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
Xdebug | http://xdebug.org | xdebug-general@lists.xdebug.org
twitter: @derickr and @xdebug
Received on Fri Nov 20 2015 - 16:16:25 GMT

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST