[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: opening multiply reverse tunnels in one session
[Thread Prev] | [Thread Next]
- Subject: Re: opening multiply reverse tunnels in one session
- From: Oleksandr Shneyder <o.shneyder@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 10 Jan 2014 12:37:31 +0100
- To: libssh@xxxxxxxxxx
Hello Andreas, Am 10.01.2014 09:38, schrieb Andreas Schneider: > On Sunday 05 January 2014 19:04:01 Oleksandr Shneyder wrote: >> Hello, >> >> is it possible to open several reverse tunnels in one session? There is >> no problem with direct tunnel, I can simple create a channels with >> ssh_channel_new for every new tunnel that I need and then open >> forwarding with ssh_channel_open_forward. > > Sure, ssh_forward_accept() returns the opened channel. See the tutorial and > the RFC which explains how it works. > > http://tools.ietf.org/html/rfc4254#section-7.1 > >> In case of reverse tunnel it seems that I only can listen to one port. >> There is an example on >> http://api.libssh.org/master/libssh_tutor_forwarding.html how to create >> reverse tunnel and forward the port 8080. But what if I need to forward >> more services in one ssh session? > > Then request more ports on that session ... :) This is the point, how can I request more than one port on session? I requesting a port with: ssh_forward_listen, for example to listen on port 9080: rc = ssh_forward_listen(session, 0l, 9080, &bound_port) that works, I can accept incoming connections with ssh_forward_accept() but now I need to listen one more port (9090) so I trying to call ssh_forward_listen again to request other port: rc = ssh_forward_listen(session, 0l, 9080, &bound_port) and it fail with error "Invalid state in start of global_request()", because function global_request in channels.c need ssh_session to be in state SSH_CHANNEL_REQ_STATE_NONE but sessions state is different after first call of ssh_forward_listen So it seems, that I can call ssh_forward_listen only once and request only one port on a session, or there are other methods to request ports on sessions? And even if it would be possible to call ssh_forward_listen more than once, for example: rc = ssh_forward_listen(session, 0l, 9080, &bound_port); rc = ssh_forward_listen(session, 0l, 9090, &bound_port); and then accept incoming connections with channel=ssh_forward_accept(); how can I know if new connection is on port 9080 or 9090 ? In libssh2 for example, I can create "listeners" for each port: LIBSSH2_LISTENER *listener_9080=libssh2_channel_forward_listen(session,9080); LIBSSH2_LISTENER *listener_9090=libssh2_channel_forward_listen(session,9090); and after that accept connections on each listener: channel_9080 = libssh2_channel_forward_accept(listener_9080); channel_9090 = libssh2_channel_forward_accept(listener_9090); But with libssh I steel can not forward more as one port... >> >> It seems to be possible open several reverse tunnels in one session with >> libssh2. But my project already uses libssh long time and I don't want >> to switch to libssh2. So I wondering if I can make the same with libssh. > > > See above :) > regards -- ---------------------------------------------------- Oleksandr Shneyder | Email: o.shneyder@xxxxxxxxxxxxx phoca GmbH | Tel. : 0911 - 14870374 0 Bräuhausgasse 9 | Fax. : 0911 - 14870374 9 D-82205 Gilching | Mobil: 0163 - 49 64 461 Geschäftsführung: Dipl.-Inf. Oleksandr Shneyder Amtsgericht München | http://www.phoca-gmbh.de HRB 196 658 | http://www.x2go.org USt-IdNr.: DE281977973 ----------------------------------------------------
Attachment:
signature.asc
Description: OpenPGP digital signature
Re: opening multiply reverse tunnels in one session | Oleksandr Shneyder <o.shneyder@xxxxxxxxxxxxx> |
opening multiply reverse tunnels in one session | Oleksandr Shneyder <o.shneyder@xxxxxxxxxxxxx> |
Re: opening multiply reverse tunnels in one session | Andreas Schneider <asn@xxxxxxxxxxxxxx> |