I am attempting to create an SSH client to connect to a custom SSH server. When running the program I receive :
Exception Details: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Renci.SshNet.SshClient'.
frontend code
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Enabled = true;
SSHSubmits.SIDSubmitByte();
}
behind code
private static SshClient ClientCreate()
{
var Host = "10.0.0.195";
var Port = int.Parse("42078");
var Username = "abc";
var keyFile = new PrivateKeyFile(@"C:\Users\Administrator\.ssh\ACdb_Philos_Div1");
var keyFiles = new[] { keyFile };
var methods = new List<AuthenticationMethod>();
methods.Add(new PrivateKeyAuthenticationMethod(Username, keyFiles));
var coninfo = new ConnectionInfo(Host, Port, Username, methods.ToArray());
using (SshClient sshclient = new SshClient(coninfo))
return sshclient;
}
public static void SIDSubmitByte()
{
ClientCreate().Connect();
}