PortProxy 是一个Windows本地端口转发管理工具,使用了Windows内置命令netsh。
Linux现假定host A可建立到host B的ssh连接。
既可以使host A上端口P1的数据,通过A–>B的ssh隧道,到达host C的端口P2,这称为本地端口转发。
也可以使host B上端口P1的数据,通过B–>A的ssh隧道,到达host C的端口P2,这称为远程端口转发。
-L listen-port:host:port Forward local port to remote address -R listen-port:host:port Forward remote port to local address These cause ssh to listen for connections on a port, and forward them to the other side by connecting to host:port. -N Do not execute a shell or command. -f Fork into background after authentication. -g Allow remote hosts to connect to forwarded ports.
举例:想让服务器10.6.8.12将2022端口上的请求转发至22端口,这样也能通过2022端口ssh连接了。
ssh -gL 2022:localhost:22 10.6.8.12
不加-g,会在127.0.0.1:2022上监听,加了-g,会在0.0.0.0:2022上监听。
这条命令会同时登陆到服务器上,登出时隧道也关闭,如果想让其在后台运行,加上-fN参数。



