Send Telnet command inside a SSH Tunnel

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

1 Answer

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 user@192.168.1.2 -L 2222:10.0.1.2:23 -N
telnet localhost 2222
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like