ssh dynamic port forwarding

后端 未结 1 600
遥遥无期
遥遥无期 2021-01-23 16:46

I want to use ssh dynamic port forwarding in my android code.

I used the library jcraft, but unfortunately this library doesn\'t support

相关标签:
1条回答
  • 2021-01-23 17:02

    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.

    0 讨论(0)
提交回复
热议问题