[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need help.
[Thread Prev] | [Thread Next]
- Subject: Re: Need help.
- From: Aris Adamantiadis <aris@xxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Sun, 13 Sep 2009 11:14:19 +0200
- To: libssh@xxxxxxxxxx
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. | Taras Halturin <halturin@xxxxxxxxx> |
Need help. | Taras Halturin <halturin@xxxxxxxxx> |