Search code examples
javasshtunnel

Use JSCH (java) to tunnel a socket under a closed port


I found JSCH library for SSH access, I have a socket: Socket socket = new Socket(irc.dba.biz, 6667), that has to be tunneled using tunnel.shellmix.com tunnel service on port 22...

How do I do it? I don't find docummentation that lets me tunnel to an external tunneling server....! (I am a noob on this, since I discovered this process two days ago)...


Solution

  • Refer to http://www.jcraft.com/jsch/examples/PortForwardingL.java.html

    If you give "6667:irc.dba.biz:6667" as the parameter for the local port-forwarding, you will get the following socket connection,

      Socket socket = new Socket("127.0.0.1", 6667);