sshj icon indicating copy to clipboard operation
sshj copied to clipboard

Jump example not for 0.27.0?

Open gulo-gulo opened this issue 5 years ago • 2 comments

Hi @hierynomus,

Thanks a ton for this repo, it saves me so much time.

So, I'm using 0.27.0 (need the RSA support), and I also need to perform "jump" logic (https://github.com/hierynomus/sshj/blob/master/examples/src/main/java/net/schmizz/sshj/examples/Jump.java), but the DirectConnection class and the newDirectConnection() method are not there anymore (looks like the examples use 0.24.0?)

Is there a newer way to accomplish this or perhaps I'm missing something somewhere in this repo that demonstrates how to do it?

Thanks!

gulo-gulo avatar Aug 07 '19 15:08 gulo-gulo

Thanks to your hint, I found the necessary parts in 0.27.0 to open a direct channel successfully:

            final String DIRECT_CHANNEL_LOCAL_ADDR = "localhost";
            final int DIRECT_CHANNEL_LOCAL_PORT = 65536;
...
            SSHClient client = new SSHClient();
...
            var forward = new LocalPortForwarder.DirectTCPIPChannel(
                    client.getConnection(),
                    null,
                    new LocalPortForwarder.Parameters(
                            DIRECT_CHANNEL_LOCAL_ADDR,
                            DIRECT_CHANNEL_LOCAL_PORT,
                            "localhost", // remote host
                            22 // remote ip
                    )
            );

            forward.open();

            var input = forward.getInputStream();
            var output = forward.getOutputStream();

kellerkindt avatar Aug 19 '19 17:08 kellerkindt

@kellerkindt Can you expand on your example? How do I then use that input/output stream in making a second SSH connection?

drosenbauer avatar Mar 03 '20 20:03 drosenbauer