Create and Test an SSH Tunnel

From WickyWiki
Revision as of 10:04, 15 August 2024 by Wilbert (talk | contribs) (Created page with "Category:Raspberry Pi Category:202408 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 <source lang=bash> w3m http://localhost:80 </source> What are my IP addresses: <source lang=bash> ifconfig </source> Forward it to a differe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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 }' )