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

=?gb18030?b?u9i4tKO6ILvYuLSjuklzIHNzaCBhcHByb3ByaWF0?==?gb18030?b?ZSBmb3IgdGhpcyB1c2UgY2FzZT8=?=


you can check libssh/examples/ssh_client.c and samplesshd-cb.c, I used this for template, it shows the basic API usage.




------------------ 原始邮件 ------------------
发件人:&nbsp;"Christopher Morley"<chris@xxxxxxxxxxxxxxx&gt;;
发送时间:&nbsp;2020年4月13日(星期一) 凌晨0:57
收件人:&nbsp;"libssh"<libssh@xxxxxxxxxx&gt;;

主题:&nbsp;Re: 回复:Is ssh appropriate for this use case?



&gt;  An example is gnash (gnu flash) which has a client and server implementation 



Is there a more up-to-date implementation somewhere? This one appears to be more aspirational than functional (and it seems pretty dead, which makes sense)

https://github.com/strk/gnash/blob/master/cygnal/libnet/sshserver.cpp


On Sun, Apr 12, 2020 at 5:08 AM Andreas Schneider <asn@xxxxxxxxxxxxxx&gt; wrote:

On Friday, 10 April 2020 09:57:37 CEST 刘元哲 wrote:
 &gt; Hello, Chris
 &gt; 
 &gt; 
 &gt; I'm also learning libssh this few days, and found your problem when I wake
 &gt; up at afternoon :-).
 &nbsp;First of all, I think libssh tcp/ip forwarding can
 &gt; solve your problem, u need
 &gt; read&amp;nbsp;https://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-&gt; port-forwarding-explained-with-examples.html(local port forwarding
 &gt; part)&amp;nbsp;to understand what&amp;nbsp; does local port forwarding do and why
 &gt; it's an appropriate solution. Then u can read
 &gt; this&amp;nbsp;https://api.libssh.org/stable/libssh_tutor_forwarding.html It
 &gt; shows the whole architecture about tcp/ip forward on client side. It holds
 &gt; one session between client(java) and server(c++), no matter how many
 &gt; simulation processes u have, it doesn't care. I'm not familiar with java,
 &gt; but libssh is used in C, maybe u need a JNI? Anyway once u can run this
 &gt; function, the server side(sshd_tcpip_forward.c), should be able to receive
 &gt; the request. Here to make things clear, libssh is not something u can use
 &gt; automatic, it's NOT openssh, a prebuilt binary with many options u can
 &gt; choose, u need to program some codes:
 &gt; the client side in tutor only show how to open a request to server, I think
 &gt; u need to make java part connect to some localhost port, see 4321,
 &nbsp;then in
 &gt; client code, u program a event_loop, check
 &gt; here:https://api.libssh.org/stable/group__libssh__poll.html,
 &gt; ssh_add_event_fd, use socket to listen at 4321, once something arrive,
 &gt; forward it to server. Obviously u need to define what the date struct, as u
 &gt; may have many simulation processes, and how long it
 &gt; is.(read&amp;nbsp;ssh_channel_open_forward CAREFULLY!!, u must understand what
 &gt; the parameter should be). Now it's ready to send it, once server receive
 &gt; it, it also need to re-direct to ur cpp listen port, here u also need
 &gt; program with socket, like client side, use ssh_event callback.
 
 Well, if you implement the server and client side there is no need for port 
 forwarding. You can just implement the client and server with libssh to secure 
 the communication.
 
 All you need is a channel which reads and writes on both sides.
 
 
 An example is gnash (gnu flash) which has a client and server implementation 
 this way.

References:
Is ssh appropriate for this use case?Christopher Morley <chris@xxxxxxxxxxxxxxx>
=?gb18030?b?u9i4tKO6SXMgc3NoIGFwcHJvcHJpYXRlIGZvciB0?==?gb18030?b?aGlzIHVzZSBjYXNlPw==?="=?gb18030?b?wfXUqtXc?=" <945695107@xxxxxx>
Re: 回复:Is ssh appropriate for this use case?Andreas Schneider <asn@xxxxxxxxxxxxxx>
Re: 回复:Is ssh appropriate for this use case?Christopher Morley <chris@xxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org