SSH Dynamic Port Forwarding for Internet Access

dorian5
2 min readFeb 13, 2023

--

This procedure is applicable if we have a computer without Internet access, but has network access to a computer that does have Internet access (i.e. lab environments), and we don’t have a Hotspot or wi-fi access to a cell phone that can tether.

Definitions:

  • Client PC: The lab computer with no Internet access
  • Server PC: The computer with Internet access. In this example, the server is Windows-based.

Client PC Setup

  1. If the client needs a current browser, we can download full installs of Firefox at the below link. We can then copy the full install to the client and install it. https://www.mozilla.org/en-US/firefox/all/#product-desktop-release. Alternately google “firefox offline install” if the link doesn’t work. Firefox has better control of proxy settings than Chrome, so it is preferred in this situation.
  2. Set up a temporary proxy session in Firefox, which will work until we can install FoxyProxy:
  3. From Firefox Settings → type “proxy” in search bar and select the “Settings” button under Network Settings
  4. Select Manual proxy configuration radio button
  5. Under SOCKS Host, enter “localhost” and set port to 1080
  6. Click OK
  7. Download plink.exe, which is a command line ssh client from the creators of Putty, and copy it to the client PC. https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Server PC Setup

  1. If you have the admin privileges and licensing available you can use Microsoft OpenSSH Server.
  2. Otherwise, download and install Bitvise SSH Server.

https://www.bitvise.com/ssh-server-download

  1. Bitvise Setup:
  1. Make sure the Bitvise Server is running. From the Server tab, I changed the Startup Type to Manual so that the Server isn’t always running when I don’t need it to be.
  2. Note the IP address and login creds of the server PC. In my case the IP address is 10.209.233.51 and the login is administrator.

Dynamic Port Forward

  1. From a command prompt on the client PC, change to the folder that contains plink.exe and enter:

c:\temp>plink -ssh -D 127.0.0.1:1080 administrator@10.209.233.51

  1. Type the password and hit Enter. Hit Enter again to begin the session.
  2. You should now have Internet access.
  3. As I mentioned above, you can now install the FoxyProxy browser extension in Firefox, which makes it much easier to toggle proxy servers on and off.

--

--