www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: ssh tunneling

Re: ssh tunneling

From: Peter Stuge <peter_at_stuge.se>
Date: Tue, 9 Feb 2010 10:25:15 +0100

A. Mark wrote:
> I'd like to know if ssh tunneling is possible with the library.

Yeah, local forwards are certainly possible, and maybe also remote
forwards though I'm unsure about that.

> Basically, I'm trying to access a host on a LAN

How do you want to access the internal host?

> both hosts have ssh service setup on port 22.

From this I assume that you want to access the internal host on port

For an example of how to use a direct-tcpip SSH channel (this is the
term for channels used for outbound TCP connections from the sshd)
please see example/direct_tcpip.c.

As you can see in that file you must manually pump data through the
first connection. Since libssh2 requires a fd also for the second
connection you must use pipe() and manually copy data from the first
libssh2 connection into that pipe, and vice versa.

Remember to init a new LIBSSH2_SESSION for the second connection to
the internal host.

> I also have read that putty is capable of tunneling too.

Yes - why do you bring this up?

libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-02-09

the libssh2 team