5

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.

3
  • 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. Jan 2, 2014 at 17:13
  • What you say it's correct. In other words, I want to emulate the telnet connection from the remote host Jan 2, 2014 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. Jan 2, 2014 at 17:43

1 Answer 1

12

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 192.168.1.2, and the IP address of router is 10.0.1.2, this is the command sequence to use:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .