login via ssh using ssh.net (renci) to an external device always throws invalid command

64 views Asked by At

I am using ssh.net to ssh to an external box, after running any command I always get "Invalid command\n" no matter what command I do write, there is not error in connection and I can see in Client.IsConnected = true and also if wrong password connection is not valid and program fails. Issue is that the commands always get the same reply from the box Command.Result = "Invalid command\n". If I login via putty, I can run "help" command without any issue. Other interesting fact is that linux command w shows what users are connected, so If I login via putty I can see user1 on, however with this little program this doesn't happen

namespace SSHconsole { class MainClass {

    public static void Main(string[] args)
    {
        //Connection information
        string user = "user1";
        string pass = "pass1";
        string host = "X.X.X.X";

        var connectionInfo = new PasswordConnectionInfo(host, user, pass);

        //Set up the SSH connection
        using (var client = new SshClient(connectionInfo))
        {

            connectionInfo.AuthenticationBanner += delegate (object sender, AuthenticationBannerEventArgs e)
            {
                Console.WriteLine(e.BannerMessage);
            };
            //Start the connection
            client.Connect();
            var command = client.RunCommand("help");
            Console.WriteLine(command.Result);
            client.Disconnect();
        }

    }
}

}

0

There are 0 answers