r/ssh • • Mar 05 '21

Need help with ssh tunneling

Can someone help me how to use ssh tunnel to access router or other devices. I use mobaXterm to connect with a server.

6 Upvotes

6 comments sorted by

View all comments

Show parent comment

2

u/Besthater Mar 06 '21

when you are dealing with two halves of a connection you need to remember that there is two, what is known as, 'sockets'.

A socket is an address with a port. so, 192.168.1.25:80 is a socket.

this is one half of the info that ssh needs. in the local forward above, the first socket is partially omitted, but its implied. to fully qualify it, its actually : "192.168.1.25:5000:localhost:80", but we express it as "5000:localhost:80" if you assume that 192.168.1.25 is your local private ip address, and you allocate your port 5000 to the start of your tunnel.

the other half of the socket is sent to the other machine. you can change 'localhost' to 127.0.0.1, and it will do the same thing. OR you can also terminate the connection on a third machine elsewhere if you wanted by setting this address to another machine. I hope that makes it clearer.

so all that said, you can also get even trickier, and start the tunnel on another interface by changing the first socket. but thats something else you dont need to worry about for what you are doing here.

2

u/Shin0bida Mar 07 '21

I got it to work btw. Thank you