title: Displaying Output from SSH.NET
body: <p>I am fairly new with C# and I am trying to write an SSH console application using the SSH.NET framework. So far I was able to connect to my server successfully, but now I am trying to run commands and have it display the result. Yet, my console comes out blank when I run my application. My end goal was to execute a set of commands and see the results at the end of it.</p>
  
  <p><strong>Program.cs</strong></p>
  
  <pre><code>using Renci.SshNet;
  class Program
  {
      //Login Parameter
      const String Hostname = "somePort";
      const int PortNumber = 22;
      const String Username = "username";
      const String Password = "root";
  
      static void Main(string[] args)
      {
          //Bypass Keyboard authentication
          KeyboardInteractiveAuthenticationMethod kauth = new KeyboardInteractiveAuthenticationMethod(Username);
          PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(Username, Password);
          kauth.AuthenticationPrompt += new EventHandler&lt;Renci.SshNet.Common.AuthenticationPromptEventArgs&gt;(HandleKeyEvent);
  
          //Grab info for connections
          ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, PortNumber, Username, pauth, kauth);
  
          //Connect
          using (SshClient client = new SshClient(connectionInfo))
          {
              try
              {
                  //Connect to server
                  client.Connect();
                  Console.WriteLine("Connection successful");
  
                  var command = client.CreateCommand("ls");
                  var result = command.Execute();
                  command.Execute();
                  Console.WriteLine(result);
  
                  //Disconnect from server
                  client.Disconnect();
              }
              //Show exp message
              catch (Exception exp)
              {
                  throw exp;
              }
          }       
      }
  
      //Handle two step auth
      static void HandleKeyEvent(Object sender, Renci.SshNet.Common.AuthenticationPromptEventArgs e)
      {
          foreach (Renci.SshNet.Common.AuthenticationPrompt prompt in e.Prompts)
          {
              if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
              {
                  prompt.Response = Password;
              }
          }
      }
  }
  </code></pre>