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

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


Re-Update:
After compared the different result between ssh_message_global_request_reply_success before ssh_channel_open_reverse_forward or after it
I found ssh_channel_listen_forward want a reply, so if I reply it immediately, the ssh client then said "ssh_global_request: Global request tcpip-forward success"and  can't receive ssh_channel_open_reverse_forward request.
Otherwise if I choose to reply it after ssh_channel_open_reverse_forward, the  ssh_channel_listen_forward will hang there, continue wait for the 
reply.


So how to solve this dilemma...


Thanks,
Yuanzhe




------------------ 原始邮件 ------------------
发件人:&nbsp;"我自己的邮箱"<945695107@xxxxxx&gt;;
发送时间:&nbsp;2020年4月8日(星期三) 晚上10:36
收件人:&nbsp;"libssh"<libssh@xxxxxxxxxx&gt;;

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



Re-Update:
After change the sshd global_reply_success func location, now I can see the server ssh client side receive the ssh_packet:


ssh_global_request: Sent a SSH_MSG_GLOBAL_REQUEST tcpip-forward
ssh_socket_pollcallback: Poll callback on socket 632 (POLLIN POLLOUT ), out buffer 0
ssh_packet_socket_callback: packet: read type 90 [len=80,padding=13,comp=66,payload=66]
ssh_packet_process: Dispatching handler for packet type 90
ssh_packet_channel_open: Clients wants to open a forwarded-tcpip channel
ssh_packet_need_rekey: packet: [data_rekey_needed=0, out_blocks=4, in_blocks=31
ssh_socket_pollcallback: sending control flow event
ssh_packet_socket_controlflow_callback: sending channel_write_wontblock callback
ssh_socket_pollcallback: Poll callback on socket 632 (POLLOUT ), out buffer 0
ssh_socket_pollcallback: sending control flow event
ssh_packet_socket_controlflow_callback: sending channel_write_wontblock callback



However, I can't use ssh_message_get to get the channel open request, the ssh client hang here.
So... Still need some help :-)


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

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



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

Archive administrator: postmaster@lists.cynapses.org