Skip to content

Instantly share code, notes, and snippets.

@Alec1017
Created April 3, 2024 22:14
Show Gist options
  • Save Alec1017/e2297cba19017c85a472be8f3310e944 to your computer and use it in GitHub Desktop.
Save Alec1017/e2297cba19017c85a472be8f3310e944 to your computer and use it in GitHub Desktop.
Connecting to a browser over SSH

Use case

There have been times that I have not been on my LAN but I needed to open up a port in my router. I figured that there might be a way that I could use one of my machines running locally to act as a proxy to serve me web traffic via a VPN connection over SSH.

Connecting

Make sure the server connected to the LAN can serve unencrypted traffic on port 80:

sudo ufw allow 80 comment 'temporary access to web traffic'

Open an SSH connection on the machine outside of the LAN. Make sure to use a port that you know isnt taken:

# -D: bind to the port.
# -C: Requests compression of all data.
# -N: Specifies that a remote command not be executed. This is useful for just forwarding ports.
ssh -D 42069 -C -N <user>@<ip-of-LAN-machine>

For this step, i use tailscale as my VPN to access my LAN machine.

This is where results may vary. I have only tested this on macOS so I do not have instructions for any other OS. From here, the proxy needs to be configured in settings. Go to:

System settings > search "proxies" > SOCKS proxy

Then, specify the server and port:

server: 127.0.0.1
port: 42069

Thats it! Now you should be able to access IP addresses that are only available to your LAN from your remote machine.

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