Create and Test an SSH Tunnel

From WickyWiki


If you want to temporarely make a local service and port available in your network you can forward it using an SSH tunnel.

Fot this example you will need a local webservice and webpage to make sure the forwarding works as expected.

Check to see if we have something on localhost:80

w3m http://localhost:80

What are my IP addresses:

ifconfig

Forward it to a different port, login to ssh user1@192.168.1.2

ssh -fN -L 192.168.1.2:12345:localhost:80 user1@192.168.1.2

It should now be accessable via http://192.168.1.2:53682 from another location in your network.

Stop the tunnel

ps aux | grep '192.168.1.2:53682' | grep -v 'grep'
kill -9  $( ps aux | grep '192.168.1.2:53682' | grep -v 'grep' |  awk '{ print $2 }' )