[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need help.
[Thread Prev] | [Thread Next]
- Subject: Need help.
- From: Taras Halturin <halturin@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Sun, 13 Sep 2009 12:56:04 +0400
- To: libssh@xxxxxxxxxx
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 gbooleando_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. | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
| Re: Need help. | Andreas Schneider <mail@xxxxxxxxxxxx> |