Search code examples
c#.netsshtelnetssh.net

How to send command to Telnet over SSH connection


I am using SSH.NET library to connect to a remote server and then initiate a Telnet session. I am able to do that using SshClient class. My problem is that now I am not able to send commands to that Telnet connection using the connected SSH client. The RunCommand method sends the command to the server instead to the Telnet session. How can I achieve that.

Thank you,
Usman


Solution

  • Use SSH.NET to forward a localport to the remote Telnet server through the SSH connection.

    And then use some C# Telnet library. to connect to the local forwarded port.

    You can start with this question:
    Connection to MySQL from .NET using SSH.NET Library
    Just replace the MySqlConnection with your Telnet client class.