How to use sshj to tunnel through an intermediate server without using local port forward

StackOverflow https://stackoverflow.com/questions/15988098

  •  03-04-2022
  •  | 
  •  

Question

I am trying to use sshj to tunnel through an gateway (jump point) server:

A -> B -> C

The caveat is that I need to do this without setting up a local port forward. I need to make a direct connection to server B, then make another ssh connection to server C.

Was it helpful?

Solution

I wasn't able to find a solution that didn't utilize local port forwarding. A potential non port forward solution could be to get a PTY from the first connection, then just execute ssh; but, in initial testing the new session did not seem to transfer over for me.

The best solution I found for this tunneling requirement was found in a piece of code here in the overthere project.

UPDATE: I answered a similar question with some code here: https://stackoverflow.com/a/16023513/311525

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top