[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

=?gb18030?b?u9i4tKO6SE9XIHRvIHVzZSBzc2hfY2hhbm5lbF9v?==?gb18030?b?cGVuX3JldmVyc2VfZm9yd2FyZCBmdW5jdGlvbiB0?==?gb18030?b?byBpbXBsZW1lbnQgYSByZXZlcnNlIHR1bm5lbD8=?=


Update:
I open the log level to 3, found out my "server ssh client" side never received the channel_open request,
although my local sshd definitely has sent that:
channel_open: Creating a channel 43 with 64000 window and 32768 max packet
ssh_packet_need_rekey: packet: [data_rekey_needed=0, out_blocks=31, in_blocks=8
packet_send2: packet: wrote [type=90, len=80, padding_size=13, comp=66, payload=66]
channel_open: Sent a SSH_MSG_CHANNEL_OPEN type forwarded-tcpip for channel 43



Here my local sshd hang, and server client raised the error "No channel request of this type from server".
I tried brute force all messages on "server ssh client", but unfortunately the server is windows, and vcpkg installed libssh didn't contain mics.h,
so I don't know how to hardcode a message traverse func, BTW, message callback also not work, maybe it only worked on sshd?


Thanks,
Yuanzhe
------------------ 原始邮件 ------------------
发件人:&nbsp;"我自己的邮箱"<945695107@xxxxxx&gt;;
发送时间:&nbsp;2020年4月8日(星期三) 凌晨3:13
收件人:&nbsp;"libssh"<libssh@xxxxxxxxxx&gt;;

主题:&nbsp;HOW to use ssh_channel_open_reverse_forward function to implement a reverse tunnel?



Hi,
I'm trying to implement a simple ssh reverse tunnel with libssh. The condition is I have a home computer(local), and a development server(server), the server is behind a firewall(NAT) and I want program with libssh to do intranet penetration.



I run a client on server, connect to sshd on local, then ssh_channel_listen_forward &amp;&amp; ssh_channel_accept_forward as tutorial said.
But accept function always failed with error ''waiting for incoming connection: No channel request of this type from server''.


So turn to the local sshd side, I have registered global_request function(Here I also have a question: what's the difference between message callback and global_request callback? I thought I can handle this kind global_request in message callback, so if I both have message callback and global_request callback, does the global_request come through message callback and global_request callback both?)In it I have handled reply_success, open socket on local, listen to it, allocate a new channel, and call ssh_channel_open_reverse_forward.


I guessed I need another sshd on server, to communicate with this channel. But now I don't have code it because I'm not sure whether ssh_channel_accept_forward can handle this situation? Please clarify the architecture here, Thanks!


I also stuck at ssh_channel_open_reverse_forward function, it never return. I believe the problem is parameter, remotehost/remoteport/sourcehost/sourceport. I have read the comment, see if I want the local sshd listen at 2222, should I set remotehost as "localhost", remoeport as "2222"? Then what is the sourcehost/souceport represent? the server client connected to my local sshd? Since the server here is in NAT, how could I get it's IP?


Please kindly give me some hint on here, especially how the local sshd reverse connect to the server sshd. I tried use openssh -R, I saw without a server side sshd, the tunnel can't be established. So I thought there must be some mechanism, which I need to use ssh_channel_open_reverse_forward &amp;&amp; ssh_channel_accept_forward &amp;&amp; some magic function :-). Show me the mystery here, THANK U!


Appreciate your patient,
HAVE A NICE DAY!
Yuanzhe

References:
HOW to use ssh_channel_open_reverse_forward function to implement a reverse tunnel?"=?gb18030?b?wfXUqtXc?=" <945695107@xxxxxx>
Archive administrator: postmaster@lists.cynapses.org