Hi Team,
I want to build a web application(MVC) with feature to execute (PuTTY) commands online. I implemented the sample code as below
public string ComponentProMethod(SSHModel model)
{
// Create an SshClient object.
SshClient client = new SshClient();
string response = "";
try
{
// Sftp sftp = new Sftp();
client.Config.KeyExchangeAlgorithms = ComponentPro.Net.SecureShellKeyExchangeAlgorithm.DiffieHellmanGroup1SHA1;
// Connect to the specified server.
client.Connect(model.host);
// Authenticate.
client.Authenticate(model.username, model.password);
client.Timeout = 25000 * 2;
// Create a shell object in auto-processing mode.
TerminalShell shell = client.CreateShell(true);
// Send the command to the SSH server and read response.
response = shell.ExecuteCommand(model.command);
// Close the connection.
client.Disconnect();
}
catch (Exception se)
{
response = "An SSH exception occurred: " se.Message;
}
finally
{
// Close the connection.
client.Disconnect();
}
return response;
}
When SshClient creating the remote shell (TerminalShell shell = client.CreateShell(true)), then system throw error 'Response reading timed out'. I also tried with manual processing on creating shell, but failed to get command response.
I also checked https://www.componentpro.com/qa/sshshell-response-reading-timed
Please look into the matter
Thanks in Advance
asked 12/12/2019 3:41:00 PM