openDirectTcpipTransport

fun openDirectTcpipTransport(remoteHost: String, remotePort: Int, originAddr: String = LOCALHOST, originPort: Int = 0): TransportFactory?(source)

Create a TransportFactory that tunnels through this SSH connection.

Opens a direct-tcpip channel to remoteHost:remotePort and wraps it as a Transport, allowing a second SshClient to connect through this connection without transiting the kernel network stack (jump host / ProxyJump pattern).

val jump = SshClient("jump.example.com", hostKeyVerifier = jumpVerifier)
jump.connect()
jump.authenticatePassword("user", "pass")

val targetConfig = SshClientConfig {
transportFactory = jump.openDirectTcpipTransport("target.internal", 22)
hostKeyVerifier = myVerifier
}
val target = SshClient(targetConfig)
target.connect()

Return

TransportFactory for use in SshClientConfig, or null if not authenticated

Parameters

remoteHost

Host reachable from the SSH server to connect to

remotePort

Port on the remote host

originAddr

Originator address reported to the server

originPort

Originator port reported to the server