ssh dynamic port forwarding

雨燕双飞 提交于 2019-12-02 11:05:23

JSCH is a Java implementation of the SSH protocol. It's not a complete reimplementation of the OpenSSH ssh command-line utility. In the case of the dynamic proxy feature, JSCH provides the ability to tunnel TCP connections through an SSH session, but it doesn't provide the SOCKS proxy server needed for the client to receive the connections which are to be forwarded.

To make this work, you would embed a SOCKS proxy into your application. When a client connects to the application's SOCKS port (the equivalent of port 10000 in your example), it will use the SOCKS protocol to tell your application what host and port it wants to be connected to.

Then your application--which has presumably used JSCH to create an SSH session to some remote server--would use JSCH to open a "direct-tcpip" channel to the host and port requested by the client. Then your application would relay data between the direct-tcpip channel and the client which requested the proxy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!