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:
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:


What just happened?


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 [email protected] " while date ; do sleep 10 ; done"


Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

You can use these HTML tags

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