Guides‎ > ‎

Reverse Proxy Tunnel

This is for the scenario where you have a remote machine that doesn't have direct internet access and a local machine which has internet access and can ssh to the remote machine. For example it might be a virtual machine in a restrictive virtual network.

# Set up an http proxy server listening on the local machine.
you@local$ sudo apt-get install polipo
# Test it.
you@local$ http_proxy=http://localhost:8123 wget -O - www.google.com | head

# Ssh to remote machine with a reverse tunnel to the proxy server.
you@local$ ssh -R 8123:localhost:8123 you@remote

# If you only want to use programs on the remote host that support
# http proxies, configure them to connect to localhost:8123. Many
# unix programs respect the http_proxy environment variable so you
# can set it with
you@remote$ export http_proxy=http://localhost:8123
# and then run stuff like
you@remote$ wget -O - www.google.com/
# If you need to run something as root, you'll need to become root
# and then set the variable again
you@remote$ sudo su -
root@remote$ export http_proxy=http://localhost:8123
root@remote$ apt-get install whatever

# If you want to use programs which don't support http proxies, there
# should be a way to set up proxychains on the remote machine to intercept
# all network access by any program and send it to the proxy. This isn't
# working yet, but would go something like this.
you@remote$ sudo su -
root@remote$ export http_proxy=http://localhost:8123
root@remote$ apt-get install proxychains
root@remote$ nano /etc/proxychains.conf
Comment out the existing proxy line at the bottom and add one that says:
http 127.0.0.1 8123
you@remote$ exit # back to your user
# Use the internet
you@remote$ proxychains wget -O - http://www.google.com/
Comments