[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need help.
[Thread Prev] | [Thread Next]
- Subject: Re: Need help.
- From: Taras Halturin <halturin@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Sun, 13 Sep 2009 14:06:35 +0400
- To: libssh@xxxxxxxxxx
No, it isnt so hard. just too lazy to do it :) i would like to have an easy way ;-) On Sun, Sep 13, 2009 at 1:49 PM, Vic Lee <llyzs@xxxxxxx> wrote: > By the way, you might think it's difficult to write your own sockets, > but in my own opinion this is an advantage over openssh. For example, in > my project I can tunnel the ssh_channel with a local unix domain socket > to improve performance; I can tunnel only one accepted connection and > free the bound port immediately, so that I can re-used the same local > port in multiple threads/processes. These are impossible when using > openssh. > > Vic > > On Sun, 2009-09-13 at 17:39 +0800, Vic Lee wrote: > > Hi, > > > > I think you will have to program with sockets yourself, that means, you > > need to: > > > > 1. call socket(),bind(),listen(),etc > > 2. once connection comes in then call channel_open_forward to get a > > ssh_channel > > 3. running a separated thread (or use select/ssh_select) to transfer > > data from the socket to the channel back and fourth. > > > > I have both experience with libssh and libssh2 and basically libssh2 > > works in exactly the same way. > > > > I don't think a library can do so much things for you, it's your duty to > > do the actual tunnelling :) > > > > Vic > > > > On Sun, 2009-09-13 at 13:27 +0400, Taras Halturin wrote: > > > thanx for the answer! > > > > > > > > > It is a pity :(. so,if i can't develop second half of the port > > > forwarding routines, i'll try to use libssh2. maybe there will be easy > > > to develop this feature for me. > > > > > > > > > WBR > > > > > > > > > Taras Halturin. > > > > > > On Sun, Sep 13, 2009 at 1:14 PM, Aris Adamantiadis <aris@xxxxxxxxxxxx> > > > wrote: > > > Hello Taras, > > > > > > I am sorry the documentation let you think it would be so > > > easy... In fact channel_open_forward only does half the work, > > > this is connecting to a remote host:port from the ssh server > > > and stream it into a channel. However the port binding and the > > > select loop (to verify if data is arriving and dispatching it) > > > is unfortunately up to you. > > > > > > Looking at the select_loop in sample.c would be a good > > > start-up for you, even if we should consider writing a working > > > example in the examples directory. The functionnality you > > > expected may be available in the 0.5 release. > > > > > > Andreas, Maybe we should make clear into the documentation > > > about what I just stated above. I also only see online > > > documentation for the 0.4.0 branch when the stable branch is > > > still 0.3.x. Could you have a look ? > > > Regards, > > > > > > Aris > > > > > > Taras Halturin a écrit : > > > > > > > > > Hi all! > > > > > > i'm trying to use libssh for the port forwarding and > > > it doesnt work for me :(. I need to forward remote > > > port to the local host like this: > > > ssh -L 22222:localhost:8222 fantom@xxxxxxxxxxxxx > > > > > > here is the code: > > > > > > static gboolean > > > do_open_channel (gchar *username, gchar *password, > > > gchar *remote, > > > guint remote_port, guint > > > local_port) > > > { > > > SSH_SESSION *ssh = ssh_new(); > > > SSH_OPTIONS *opts = ssh_options_new(); > > > CHANNEL *ch = NULL; > > > > > > ssh_options_set_port (opts, 22); > > > ssh_options_set_host (opts, remote); > > > ssh_set_options (ssh, opts); > > > > > > if (ssh_connect(ssh) != SSH_OK) > > > { > > > g_warning ("Error at connection :%s > > > \n",ssh_get_error (ssh)); > > > return FALSE; > > > } > > > > > > ssh_is_server_known(ssh); > > > > > > if (ssh_userauth_autopubkey(ssh) != > > > SSH_AUTH_SUCCESS) > > > { > > > g_warning ("Authenticating with pubkey: %s > > > \n",ssh_get_error(ssh)); > > > if (ssh_userauth_password (ssh, username, > > > password) != SSH_AUTH_SUCCESS) > > > { > > > g_warning ("Authentication with password failed: %s > > > \n",ssh_get_error > > > (ssh)); > > > return FALSE; > > > } > > > } > > > > > > ch = channel_new (ssh); > > > > > > if (channel_open_forward (ch, remote, remote_port, > > > "127.0.0.1", > > > local_port) != SSH_OK) > > > { > > > g_warning ("Error when opening forward:%s\n", > > > ssh_get_error (ssh)); > > > return FALSE; > > > } > > > > > > g_debug ("Chanel is forwarded"); > > > > > > return TRUE; > > > //channel_close(channel); > > > //channel_free(channel); > > > //ssh_disconnect(ssh); > > > } > > > > > > > > > i'm calling this func with args: > > > > > > do_open_channel ("fantom","megapass", "myremote.host", > > > 8222, 22222); > > > > > > No errors happend, "Chanel is forwarded" has printed, > > > but i can't see the listener on the 22222 port. What > > > is wrong? Could somebody help me? > > > > > > WBR > > > > > > Taras Halturin. > > > > > > > > > > > > > > > > > > > > > >
Re: Need help. | "Preston A. Elder" <prez@xxxxxxxx> |
Need help. | Taras Halturin <halturin@xxxxxxxxx> |
Re: Need help. | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
Re: Need help. | Taras Halturin <halturin@xxxxxxxxx> |
Re: Need help. | Vic Lee <llyzs@xxxxxxx> |
Re: Need help. | Vic Lee <llyzs@xxxxxxx> |