Creating a SSH Tunnel in a MAC

Posted by Anandhan Subbiah on Dec 6, 2007 in Technical ArticlesNo comments

Typically there are two machines involved when creating a SSH Tunnel.

1) The machine with the public facing IP.

2) The machine which does is not available to the public but certain ports are open for outside access. For example if mysql is running on the box then port 3306 is reachable using the public facing machine.

Here is the command to do this:

ssh -N -L 1222:private.machine.com:3306 user@public.machine.com

-N means that no shell is required

-L is the localport ( which means you can connect to 127.0.0.1:1222 to access the mysql instance inside a firewall. You cannot use localhost here as mysql goes crazy and tries to establish a direct socket connection to the local host ignoring the tunnel that you created. )

private.machine.com:3306 host name and port of the machine hosting mysql.

user@public.machine.com credentials to the public facing machine.

Share

Leave a comment