I want to connect my personal computer to some routers via Telnet, for managing them.

Actually, my routers is in another network. I open the console, make a SSH connection to the Main Mahcine, and then make a Telnet.

I want to cover that intermediate connection with a SSH tunnel, and directly make a telnet binding for example, the port 2222 to the remote server:22

Finding in Google, I see a easy way to create SSH Tunnel

ssh -f user@server -L 2222:server:22

-L Binds the local port to the remote machine:port -f force to stay background

But now, I don't know how can I send telnet through the SSH tunnel, how can I reference the source, using the tunnel?

Thank you.

  • if you point your telnet client to localhost:2222 it will be sent through your tunnel to port 22 on the server, but I don't think thats what you want, since telnet cannot talk ssh. – Frank Thomas Jan 2 '14 at 17:13
  • What you say it's correct. In other words, I want to emulate the telnet connection from the remote host – Alex Deiwor Jan 2 '14 at 17:18
  • I think you are a little confused on how tunneling works. you describe a tunnel between two ports (neither of which is the ssh port 22), and then tell ssh to tunnel between them, using ssh ports, so you never tell ssh to use ssh, you tell it,'I want to tunnel telnet from local:2222 to server:23'. but all this seems futile since you are telneting into the routers, not the server. – Frank Thomas Jan 2 '14 at 17:43

Since it's a local port, you can reference it using localhost.

Let's assume that the main machine is called main, and the router behind this machine is called router. The following command sequence should work:

ssh -f user@main -L 2222:router:23 -N
telnet localhost 2222

Given that the IP address of main is, and the IP address of router is, this is the command sequence to use:

ssh -f user@ -L 2222: -N
telnet localhost 2222
  • But sending telnet to local host, where I specify the IP of the specific router I want to connect to? – Alex Deiwor Jan 2 '14 at 17:17
  • Updated my solution with more details (: – yjwong Jan 2 '14 at 17:20
  • It Works! Thank you yjwong. I just edited your answer adding -N to the command line in order to work. – Alex Deiwor Jan 3 '14 at 8:51
  • What is the telnet behavior if the remote server is down? – Alban Mar 15 '17 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.