I can't seem to make this library to work. I'm doing something pretty straightforward but still I can't manage to do it.
client.Connect();
client.RunCommand("sudo passwd test");
Thread.Sleep(1000);
client.RunCommand("testtest");
Thread.Sleep(1000);
client.RunCommand("12345");
Thread.Sleep(1000);
client.RunCommand("12345");
bool primera = true;
client.Disconnect();
If I try then to login with test using the credentials just posted it fails. But if I do the same commands through normal SSH through my terminal I can log in. Why SSH.NET is not executing those commands?
The problem is because after you run
client.RunCommand("sudo passwd test");
a program is running, waiting for input. TheRunCommand
method won't actually run the command until after the program returns.I encountered the same problem when trying to run
su - <login>
and found the following workaround...