Archived Forum Post

Index of archived forum posts

Question:

Java SSH port forwarding

Apr 07 '15 at 11:11

I am attempting to set up an SSH tunnel between the localhost and a remote server. I would like for a client to be able to connect to port 27002 on the localhost and have the connection tunneled to port 27002 on the remote host. There is an SSH server listening at port 2222 on the remote host. The remote host IP is 128.1.1.10. Below is the output of the debug messages, followed by the code I am using to set up the tunnel.

Created key from file: true
Set auth key: true
ChilkatLog:
  SetSshAuthenticationKey(1ms):
    DllDate: Mar  6 2015
    ChilkatVersion: 9.5.0.48
    UnlockPrefix: Anything for 30-day trial
    Architecture: Little Endian; 64-bit
    Language: MAC OS X Java
    VerboseLogging: 1
    Success.
  --SetSshAuthenticationKey
--ChilkatLog

Authenticated: true
Passed is: false
ChilkatLog:
  BeginAccepting(1033ms):
    DllDate: Mar  6 2015
    ChilkatVersion: 9.5.0.48
    UnlockPrefix: Anything for 30-day trial
    Architecture: Little Endian; 64-bit
    Language: MAC OS X Java
    VerboseLogging: 1
    listenPort: 27002
    destPort: 27002
    destHostname: 128.1.1.10
    Listen thread did not start.
    Failed.
  --BeginAccepting
--ChilkatLog

Done

    public void connect() throws Exception {
        NativeUtils.loadLibraryFromJar("/libchilkat.jnilib");
        CkSshTunnel ssh = new CkSshTunnel();
        ssh.put_VerboseLogging(true);
        ssh.put_KeepConnectLog(true);

//  Any string automatically begins a fully-functional 30-day trial.
        boolean success = ssh.UnlockComponent("Anything for 30-day trial");
        if (success != true) {
            System.out.println(ssh.lastErrorText());
            return;
        }

        ssh.put_DestHostname(remoteServerIp);
        ssh.put_DestPort(remotePort);

        ssh.put_SshHostname(remoteServerIp);
        ssh.put_SshPort(serverSshPort);
        ssh.put_SshLogin(serverUsername);

        ssh.put_DebugLogFilePath(debugFilePath);

        CkSshKey key = new CkSshKey();
        String keyString = key.loadText(certFile);

        boolean b = key.FromOpenSshPrivateKey(keyString);
        System.out.println("Created key from file: " + b);

        b = ssh.SetSshAuthenticationKey(key);
        System.out.println("Set auth key: " + b);

        System.out.println(ssh.lastErrorText());
        System.out.println("Authenticated: " + success);
        if (success != true) {
            System.out.println("Success is: " + ssh.lastErrorText());
            return;
        }

        boolean passed = ssh.BeginAccepting(localport);
        System.out.println("Passed is: " + passed);

        System.out.println(ssh.lastErrorText());

    }

Answer

If you wish, I'll post a new build that may fix this problem..


Answer

Here are new Java builds (for MAC OS X) that may fix the problem:

http://www.chilkatsoft.com/download/preRelease/chilkatJava-9.5.0-jdk6-macosx.tar.gz

http://www.chilkatsoft.com/download/preRelease/chilkatJava-9.5.0-jdk7-macosx.tar.gz

http://www.chilkatsoft.com/download/preRelease/chilkatJava-9.5.0-jdk8-macosx.tar.gz