Peter Stuifzand

Use ssh as a SOCKS proxy

At the moment I work from another place than home and sometimes I need to get on the internal network. Normally you would VPN for that kind of thing. But if your not scared to use SSH then it’s not that hard.

First you need to open a connection to your internal network.

ssh -D 9000 hostname

The -D 9000 option will open a port and create SOCKS proxy on your local machine. This allows you to send traffic to the internal network through the SSH connection. Replace hostname with the name of the host you want to connect to.

Then you have to configure Firefox (or another browser) to send all its traffic through this proxy. You can do this in the Preferences screen. In the Preferences screen you go to Advanced, Network, Connection. Click the Settings button. This will open a screen that allows you to set all kinds of proxies. To use the SOCKS proxy you need to click the label that says ‘Manual proxy configuration’. Then fill in the text field called ‘SOCKS Host’ and set the port to 9000. Click OK and check that you still have an internet connection.

Proxy Settings

If everything still works, you should try to open the internal webpage. If it doesn’t work, then you should reset it to the original settings.

If your internal network uses a domainname with a virtual host then you should add the domains to your local /etc/hosts file. The ip address that you use should be set from the POV of the host you connect to: 127.0.0.1 is not your local machine, but the machine you connected to.

© 2023 Peter Stuifzand