Sometimes your remote computer has access to some web service that your local one doesn’t. Firewalls and local-network servers are just too frequent.
SSH comes to rescue!
Let’s say your local machine (L) wants to access remote LAN service (D, let’s say it’s MySQL database), but all you’ve got is SSH access to one of LAN’s machines (R). Here’s the command:
ssh -fN your_username_at_R@R_address -L L_port:D_address_accessible_from_R:D_port
For our database example it could look like this (assuming that database’s IP is 192.168.0.42):
ssh -fN firstname.lastname@example.org -L 3306:192.168.0.42:3306
Now just connect your MySQL client to localhost:3306 and voilà – you’d access your remote database!
Hold on! There’s one more case I dwelled upon.
Recently I got a remote service, but needed to access it from my mobile. Unfortunately I couldn’t set SSH port forwarding there, so I found that I could manipulate the command above to make my laptop proxy the service. The command looks like this:
ssh -fN your_username_at_R@R_address -L L_interface:L_port:D_address_accessible_from_R:D_port
One more thing though – you’d need to add/change one line to /etc/ssh/sshd_config, namely “GatewayPorts=clientspecified” (and for the record – I did it on Ubuntu Linux). In my case “L_interface” was IP address of my WIFI network interface (which you could look up by “ifconfig” command) which I supplied to my mobile as server address. This might not be straighforward but at least quite generic solution.