Skip to content

[Linux] Using SSH to Set Up SOCKS Proxy Port for Firefox to Browse the Web via Remote Server IP

Last Updated on 2024-08-06 by Clay

If we happen to have several remote servers with different IPs and wish to browse the web through these different IPs (for example, some services may not support local or national access), we can use SOCKS proxy ports and configure Firefox to browse the web using the IPs of these remote servers without needing to install other VPN tools.


Terminal Configuration

First, open the terminal and connect to the remote server using the following command:

ssh -D [LOCAL_PROXY_PORT] [USERNAME]@[REMOTE_SERVER_IP]


This step is recommended to be performed within tmux or screen, so you can easily check if the connection is dropped.


Firefox Configuration

First, open Firefox, click on the settings button (three horizontal lines icon), and then click the Settings option.


Scroll to the bottom to find the Network Settings section, and then click the Settings... option next to Configure how Firefox connects to the internet.


Here, we check the Manual proxy configuration, use SOCKS v5, and fill in the port corresponding to our ssh connection (I used 55555 here).


Then you can check if the browser's IP has been updated:

I am not in Japan now, so using the Firefox browser to access the web through the remote server's address was successful.


Detailed Explanation

When we use SSH tunneling and SOCKS proxy to bypass geographic restrictions or increase privacy, the principles involved include the following two main parts:

  1. SSH Tunneling: SSH tunneling uses the SSH protocol to create an encrypted channel between the local machine and the remote server, which can securely forward various network traffic. When we create an SSH tunnel with the -D option, we are actually setting up a SOCKS proxy on the local machine's port.
  2. SOCKS Proxy: SOCKS is an internet protocol that forwards network traffic through a proxy server. When our browser is configured to use a SOCKS proxy, all network requests are sent to this proxy server and relayed by it, making our application appear to be sending requests from the proxy server's IP address.

Advantages

  • Security: Since SSH tunnels are encrypted, this ensures the security of network traffic during transmission.
  • Flexibility: You can use different remote servers to bypass geographic restrictions without installing other VPN tools.
  • Privacy: Your IP address appears as the remote server's IP address, increasing privacy protection.


Considerations

  • Connection Stability: Ensure your SSH connection is stable, as a dropped connection will render the proxy unusable (hence the recommendation to use tmux or screen).
  • Network Speed: The browsing speed through the proxy depends on the network performance of the remote server and the quality of your network connection, so there may be some slowdown.
  • Security: Ensure the security of the remote server to prevent it from becoming a target of attacks.


Lastly, it should be noted that as long as the browser itself supports SOCKS proxy functionality, you can direct the traffic to the remote server without necessarily needing Firefox. Just look for the relevant settings in your browser.


References


Read More

Tags:

Leave a Reply