0

I want to use SSH.net library (https://github.com/sshnet/SSH.NET ) to execute commands on a linux box over SSH.

Here is a sample code:

        SshClient cSSH = new SshClient("13.93.231.87", 22, "user", "pass");
        cSSH.Connect();

        var cmd = "screen -S screenName";
        SshCommand x = cSSH.RunCommand(cmd);

I see x.Result, it contains following:

        x.Result = "Must be connected to a terminal.\r\n"

What does it mean? Is it not possible to use "screen" commands via Ssh.NET? Or is there another way to achieve it?

What i want to achieve is having a C# console application which executes commands on a linux box under a screen. And then I should be able to connect the same screen again and execute commands and detach screen. And continue doing that.

007coder
  • 161
  • 1
  • 13
  • Refer - http://serverfault.com/questions/21806/how-can-i-launch-a-screen-session-with-a-command-over-ssh-on-a-remote-server-fro – Prabhu Oct 21 '16 at 17:51
  • You aren't starting anything, so screen exits because it has nothing to keep open. Try something like var cmd = "screen -S screenName /bin/sh"; So you spawn a shell "inside" your new screen process. – ivanivan Oct 22 '16 at 00:28
  • See http://stackoverflow.com/a/7049314/2003763 – Thibault D. Oct 24 '16 at 13:46

0 Answers0