ssh port forwarding example

A ssh port forwarding example would be to map a remote host’s 3306 port to your local machines 3306 port over ssh.

Remote Host: 192.168.0.1
Your Host: localhost

To port forward a mysql connection on a remote host to your local host you would run:

ssh -L 3306:localhost:3306 [email protected]

Once this is mapped you can use MySQL Workbench and connect like this:

mysql ssh port forward ssh port forwarding example

 

What just happened?

ssh port forwarding ssh port forwarding example

 

Let’s say you want other folks on your network to be able to access the forwarded 3306 port on your machine.  Additionally you don’t want the connection to timeout.  You would run this command:

 ssh -L 0.0.0.0:3306:192.168.0.1:3306 [email protected] " while date ; do sleep 10 ; done"

 

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>