简体   繁体   English

如何在C#中使用Routrek Granados通过SSH连接从服务器接收数据

[英]How to receive data from server via SSH connection using Routrek Granados in C#

I am making an application to make connection through SSH with my server using Routrek Granados library in C#. 我正在制作一个使用C#中的Routrek Granados库通过SSH与服务器建立连接的应用程序。

I have done almost every thing. 我几乎做了每件事。 but not getting the way that how to receive response/data from the server. 但没有获得如何从服务器接收响应/数据的方式。

does anyone knows? 有人知道吗?

please tell me, i shall be very thankful to you. 请告诉我,我将非常感谢你。

sample piece of code is here 示例代码在这里

 var param=new SSHConnectionParameter();
            param.UserName = "username";
            param.Password = "password";
            param.Protocol=SSHProtocol.SSH2;
            param.AuthenticationType=AuthenticationType.Password;
            param.PreferableCipherAlgorithms=new CipherAlgorithm[]{CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES, CipherAlgorithm.AES128, };
            param.WindowSize = 0x1000;
            var reader = new Reader();
            var sock=new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
            sock.Connect(new IPEndPoint(IPAddress.Parse("ip address"),(port number)));
            _conn = SSHConnection.Connect(param, reader, sock);
            reader._conn = _conn;
            SSHChannel ch = _conn.OpenShell(reader);
            reader._pf = ch;
            SSHConnectionInfo info = _conn.ConnectionInfo;

In your reader class on method OnData the response that comes back you need to set to a public property and then at the end of your code up there check reader.new property. 在方法OnData的阅读器类中,返回的响应需要设置为公共属性,然后在代码结尾处检查reader.new属性。 Note that this is all asynchronous so you may need to wait I recommend a waitsignal. 请注意,这都是异步的,因此您可能需要等待,我建议您等待信号。 I have complete code if needed. 如果需要,我有完整的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM