How to set up a ssh tunnel

First, setting up a tunnel is fairly easy. Second, for some reason I can never seem to get it right. Talking to other geek friends, even those smarter than me -- there seem to be quite a few, if you ask them -- it seems everyone has problems with it. So here's the shortcut:

Start by opening the tunnel. Specify the port locally, and the port to which you are going to connect:
ssh -L 3307:localhost:3306

-L is the instruction to listen at port 3307

3307 is the port you have opened locally for the tunnel

localhost - that's you

3306 is the port opened at inevergetitgright

dummy is the user recognized on the inevergetitright server

Suppose you are doing this to set up a mysql connection on the remote server. All you do is open mysql in the normal way, but specify a port:

mysql -u asdfsd -p -P 3307 -h

Note that you have to specify "localhost" won't work!

No comments:

Post a Comment