Create a Telnet to SSH proxy

+1 vote
asked Dec 9, 2020 by marianoe (150 points)


We have an app that has Telnet connection to a server, and we need to change that to SSH. Unfortunately we don't have the sources.

One option we are considering is to create a small proxy app that would take Telnet connections and forward them to the server with SSH connection. Is that possible with Rebex?

If so, do you have any sample code for it, or at least could you let me know which classes to use? I'm looking more on the handling of Telnet connections, because we have already coded the SSH connection in another app.

Thanks a lot for your help.


1 Answer

0 votes
answered Dec 10, 2020 by Lukas Matyska (59,010 points)

This is very interesting case of use. Well, Rebex supports both Telnet and SSH protocols. Unfortunately, we have only Telnet client.

However, our API allows you to implement your own transport layer, which enables you to behave as a Telnet "receiver" as well.

I used "receiver" term, because our Telnet client object cannot act as a true Telnet server. It is due to lack of general Telnet option handling API. It means that you will be able to accept a Telnet connections, but the internals will negotiate the Telnet options automatically (for Telnet client side).

However, I wanted to try myself whether we are able to achieve such solution and I succeeded. I have prepared a sample project for you (this is why my answer is delayed).

I was able to successfully connect to one of our SSH servers using Telnet protocol. I used PuTTY and everything worked as expected. I was even able to navigate in mc using mouse.

However, please note that there are some limitations. The proxy is not capable to transmit terminal options negotiated by individual protocols. Especially: TERM_TYPE, TERM_SIZE, NEW_LINE, LOCAL_ECHO.
So, you have to setup everything on Telnet client and proxy appropriately to match SSH server settings.


  • In PuTTY:

    • select: Terminal->Local echo->Force off
    • select: Terminal->Local line editing->Force off
    • uncheck: Connection->Telnet->Return key sends...^M
  • In Proxy:

    • TERM_NAME = "xterm"
    • TERM_COLS = 80
    • TERM_ROWS = 24

Please, try the sample project and let me know whether it fulfills your needs.

commented Dec 10, 2020 by marianoe (150 points)
Oh, wow! That's so cool of you.

I'm off today but will be trying the sample code tomorrow. Will let you know how this works and if I have any additional questions.

Again, I really appreciate that you went the extra mile to propose a solution.

Best wishes,

commented Jan 25 by marianoe (150 points)
Hi Lukas,

Just wanted to say that your proxy works PERFECTLY! We are using it with a proprietary app for which we don't have the source code anymore, and it seems to work exactly as on a straight Telnet server.  Wanted to thank you a lot for that.

Now I'm also trying it with a 3rd party emulator (KEA) that has similar limitations (no SSH) and am facing a strange issue with the LocalEcho. Even though I set LocalEcho to false in the emulator, as soon as I connect that setting turns back to true. This doesn't happen when I use putty.

Any idea why this could be happening?

Best wishes,

asked Jan 27 by marianoe (150 points) Can't turn off LocalEcho in the proxy
commented Jan 27 by Lukas Matyska (59,010 points)
Yes, pls check my answer at your newly created question at