Hello,
I need help to create a connection in SSH and send a few commands (for a Linux SO).
After send those commands i need this connection alive for a while:
My code example:
namespace test
{
The problem are, they send a the first command in ssh and frozen... why?
Thanks for any help!
I need help to create a connection in SSH and send a few commands (for a Linux SO).
After send those commands i need this connection alive for a while:
My code example:
namespace test
{
public partial class Main : Form
{
string Host = 192.168.1.1;
string Username = "root";
string Password = "root";
try{
PasswordAuthenticationMethod authMethod = new PasswordAuthenticationMethod(Username, Password);
ConnectionInfo connectionInfo = new ConnectionInfo(Host, Username, authMethod);
using (var ssh = new SshClient(connectionInfo))
{
ssh.Connect();
var cmd = ssh.CreateCommand(string.Format("cd /;gzip -d serial_testmode_2016-04-21_16.tar.gz;tar -xvf serial_testmode_2016-04-21_16.tar")).Execute();
ssh.Disconnect();
ssh.Connect();
var cmd = ssh.CreateCommand(string.Format("cd root/serial_testmode")).Execute();
// Before that i need send other commands to serial communication... But i need the SSH connection alive too!
if(serialPort.IsOpen)
{
try
{
serialPORT.Write(Comand.LedsOn);
//... and goes on....
}
}
ssh.Disconnect();
}
}
}
}The problem are, they send a the first command in ssh and frozen... why?
Thanks for any help!