简体   繁体   中英

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#.

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. Note that this is all asynchronous so you may need to wait I recommend a waitsignal. I have complete code if needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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