SSH -R 实现端口映射

今天在进行远程调试的时候,发现本地的IDE的debug端口9000一直无法收到服务器的回叫. 在服务器端查看了xdebug的log,有错误信息,是说无法链接我的9000端口. 我看了ip和port都是正确的.ip是的telekom的router ip,应该是port被防火墙阻隔了吧.

我想以前一直是用vagrant来工作,虽然调试的方法也是远程remote debug, 但是本质都是在本地一个网络环境内. 今天是真正的remote debug,因为服务器是一个在我本地以外的一个生产环境的机器.(不要问我为什么要要在生产环境debug)

然后搜了一下,发现其实有解决的办法的 (链接),就是用ssh端口映射,把远端的port映射到本地来.使用ssh -R 即可.

   -R [bind_address:]port:host:hostport
-R [bind_address:]port:local_socket
-R remote_socket:host:hostport
-R remote_socket:local_socket
Specifies that connections to the given TCP port or Unix socket
on the remote (server) host are to be forwarded to the given host
and port, or Unix socket, on the local side. This works by allo‐
cating a socket to listen to either a TCP port or to a Unix
socket on the remote side. Whenever a connection is made to this
port or Unix socket, the connection is forwarded over the secure
channel, and a connection is made to either host port hostport,
or local_socket, from the local machine.

Port forwardings can also be specified in the configuration file.
Privileged ports can be forwarded only when logging in as root on
the remote machine. IPv6 addresses can be specified by enclosing
the address in square brackets.

By default, TCP listening sockets on the server will be bound to
the loopback interface only. This may be overridden by specify‐
ing a bind_address. An empty bind_address, or the address ‘*’,
indicates that the remote socket should listen on all interfaces.
Specifying a remote bind_address will only succeed if the
server’s GatewayPorts option is enabled (see sshd_config(5)).

If the port argument is ‘0’, the listen port will be dynamically
allocated on the server and reported to the client at run time.
When used together with -O forward the allocated port will be
printed to the standard output.

这样,实现了在命令行下的remote debug.但是但是,浏览器似乎一直还是不行.我把浏览器改为通过socket代理,似乎还存在问题.