telnet

Mar 14, 2014 at 4:23 PM
Edited Mar 14, 2014 at 4:23 PM
After I SSH onto the server, I would like to telnet onto a specific machine. When I do this through putty, the command I use is "telnet host -l user" and then I am asked to input a password. This is what I currently have:
  using (var ssh = new Renci.SshNet.SshClient(connectionInfo))
        {
            ssh.Connect();
            var cmd = ssh.RunCommand("telnet host -l user");                
        }
The code hangs at the "RunCommand" line, presumably waiting for the password. How do I input the password?

I am new to programming so please be patient.

Thank you in advance!
Mar 14, 2014 at 6:35 PM
I was able to get this to work using ShellStream. Here is what I used:
 using (var ssh = new Renci.SshNet.SshClient(connectionInfo))
        {
            ssh.Connect();
            Renci.SshNet.ShellStream stream = ssh.CreateShellStream("xterm", 80, 50, 1024, 1024, 1024);
            StreamReader Reader = new StreamReader(stream);
            StreamWriter Writer = new StreamWriter(stream);
            Writer.AutoFlush = true;
            Thread.Sleep(500);
            string Result = Reader.ReadToEnd();
            Writer.WriteLine("telnet host -l user");
            Thread.Sleep(500);
            Result = Reader.ReadToEnd();
            Writer.WriteLine("password");
            Thread.Sleep(500);
            Result = Reader.ReadToEnd();                
        }

Please let me know if there is a more efficient way.