Skip to content

Instantly share code, notes, and snippets.

@harikt
Forked from brentjanderson/Howto.md
Created December 23, 2021 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/4cc920cd75e100ad99f1c76f1a1e6995 to your computer and use it in GitHub Desktop.
Save harikt/4cc920cd75e100ad99f1c76f1a1e6995 to your computer and use it in GitHub Desktop.
SSH Tunneling with Firefox

Sometimes it is useful to route traffic through a different machine for testing or development. At work, we have a VPN to a remote facility that we haven't bothered to fix for routing, so the only way to access a certain machine over that VPN is via an SSH tunnel to a machine that is reachable over the VPN. Other times, I have used this technique to test internet-facing requests against sites I am developing. It is pretty easy, and if you don't use firefox regularly, you can treat Firefox as your "Proxy" browser and other browsers can use a normal configuration (Although you can also configure an entire system to use the proxy, other articles exists that discuss this potential).

  1. Open a terminal
  2. ssh -ND 9999 username@your-remote-server.com
  • ssh
  • -N - Do not execute remote commands, just open the connection for forwarding
  • D 9999 - Create a local "dynamic" forwarding port on your local machine, and route all traffic through it to the remote machine via SOCKS v4 or v5
  1. Leave the terminal open, go to Firefox
  2. Open firefox settings, search for "SOCKS" and open the Network Proxy settings button that is now highlighted
  3. Select "Manual proxy configuration"
  4. Enter localhost for the SOCKS host, 9999 for the port, and SOCKS v5 selected. Click "OK" to save it.
  • Leave the HTTP Proxy, SSL Proxy, and FTP proxy fields blank, with port 0 for each
  • If you know what to fiddle with here, consider adjusting the "No proxy for" and "Proxy DNS when using SOCKS v5", if needed

You are now routing all Firefox traffic through your remote box. To verify, Google "What is myIP address" and compare the results in Firefox with those in another browser.

Note that you must change Firefox back to "No Proxy" to disable this effect. If you do not, and you close your SSH tunnel, Firefox will be 100% inoperable until a new tunnel is opened or you revert your network proxy settings in Firefox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment