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