I am trying connect to host machibe with SSH.NET library. Here is my code;
`using(var client new SSHClient(host,port,username,password))
{
try
{
client.HostReceived += delegate (object sender, HostKeyEventArgs e {e.CanTrust = true;});
client.Connect()
if(client.IsConnected)
{
var command ="some command";
var sshcommand = client.RunCommand(command) or SShCommand sshcommand = client.CreateCommand(command); sshcommand.Execute() or client.BeginExecute();
Console.WriteLine(sshcommand.Result)
}
catch (SShConnectionException e)
{
Console.WriteLine(e.DisconnectReason);
Console.WriteLine(e);
}
}`
I tried SshClient with ConnectionInfo constructor also. Connection is establishing with host machine. However, code is givin SSHConnectonException with messages that ConnectionLost or Connection aborted in the client.RunCommand(command) or SShCommand sshcommand = client.CreateCommand(command); client.Execute() lines. When i try ssscommand.BeginExecute result is null and sshCommand.IsCompleted is false.
What i am missing? Why after succesfull connection, connection is lost in sshcommand?