Subject: Re: Port forwarding through gateway

Re: Port forwarding through gateway

From: Peter Stuge <peter_at_stuge.se>
Date: Sun, 22 Sep 2013 20:44:28 +0200

Velichko Yuriy wrote:
> I use direct tcp connection to communicate with application on remote
> machine.
> Is there a way to make port forwarding of the third computer in the local
> network that avaliable from the gateway server.
>
> Local<---Gateway<---Remote
>
> I found the example how to make this with terminal
>
> ssh -L 192.168.0.2:8080:127.1:9999 user_at_8.8.8.8 ssh -L 127.1:9999:127.1:80
> user2_at_10.1.1.2

I would recommend using ProxyCommand instead, but the result is the same.

> Can I do something similar with libssh2?

Yes you can.

> PS: Should I make two sequentially direct connection, first make
> port forwarding from gateway, and after using forwarded port make
> new forwarding from remote machine?

Correct, you need to use two sessions, and since libssh2 expects to
read data from a socket you will have to create a socketpair to pass
bytes between the forwarded connection and libssh2.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-09-22