通过 ssh 隧道远程端口转发连接 xdebug

通过 ssh 隧道远程端口转发连接 xdebug

我有一台无法通过互联网访问的家用开发机器和一台公共远程网络服务器(vps),两者都运行 debian。

在 Web 服务器上,我运行 xdebug,并在端口 9000 上输出。我通过在服务器上成功运行,检查了 xdebug 是否在端口 9000 上输出$ ./dbgpClient -p 9000

我想将其重定向到我的本地机器,正如我在许多网站上看到的那样https://derickrethans.nl/debugging-with-xdebug-and-firewalls.html

在我的服务器上,我检查了我的 /etc/ssh/sshd_config 文件:

$ cat /etc/ssh/sshd_config | grep "^[^#].*" 
ChallengeResponseAuthentication no UsePAM yes
AllowTcpForwarding yes 
GatewayPorts yes
PrintMotd no 
AcceptEnv LANG LC_* 
Subsystem   sftp    /usr/lib/openssh/sftp-server 
PasswordAuthentication yes

在本地计算机上,关闭与服务器的所有 ssh 会话后,我运行

$ ssh remoteServer -x -R 9000:127.0.0.1:9000

connect_to 127.0.0.1 port 9000: failed.每当服务器上运行 php 脚本时我都会收到消息。

我通过运行检查了本地机器上的端口 9000 是否不忙$ sudo netstat -plant | grep 9000,但没有输出。

有任何想法吗 ?

感谢那些读到这里的人……

[编辑]

如果有帮助的话,下面是我使用 -vvv 选项运行 ssh 转发命令时显示的内容:

debug3: receive packet: type 90
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 3 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen localhost port 9000, originator ::1 port 48390
debug2: fd 8 setting O_NONBLOCK
debug2: fd 8 setting TCP_NODELAY
debug1: connect_next: host 127.0.0.1 ([127.0.0.1]:9000) in progress, fd=8
debug3: fd 8 is O_NONBLOCK
debug3: fd 8 is O_NONBLOCK
debug1: channel 1: new [::1]
debug1: confirm forwarded-tcpip
debug3: channel 1: waiting for connection
debug1: channel 1: connected to 127.0.0.1 port 9000
debug3: send packet: type 91
debug2: channel 1: read<=0 rfd 8 len 0
debug2: channel 1: read failed
debug2: channel 1: close_read
debug2: channel 1: input open -> drain
debug2: channel 1: ibuf empty
debug2: channel 1: send eof
debug3: send packet: type 96
debug2: channel 1: input drain -> closed
debug3: receive packet: type 96
debug2: channel 1: rcvd eof
debug2: channel 1: output open -> drain
debug2: channel 1: obuf empty
debug2: channel 1: close_write
debug2: channel 1: output drain -> closed
debug3: receive packet: type 97
debug2: channel 1: rcvd close
debug3: channel 1: will not send data after close
debug2: channel 1: send close
debug3: send packet: type 97
debug2: channel 1: is dead
debug2: channel 1: garbage collecting
debug1: channel 1: free: ::1, nchannels 2
debug3: channel 1: status: The following connections are open:
  #0 client-session (t4 r2 i0/0 o0/0 fd 5/6 cc -1)
  #1 ::1 (t4 r3 i3/0 o3/0 fd 8/8 cc -1)

答案1

我的配置实际上是有效的,导致错误的原因是我没有在 sublime text 插件中配置断点。

只需添加一个断点即可解决问题。

相关内容