Search code examples
network-programmingsshwindows-10vpn

How to ssh into a work laptop connected to a VPN


I haven't found a question fitting the exact parameters of my situation (please excuse me if I have missed it).

For the last year remote work has been nothing but a blessing, it's the perfect set-up for me and my productivity has skyrocketed. The one blemish I'm still facing is when it comes to accessing work apps and machines (via ssh) for which a connection to the work network is required.

For that I use my work laptop and assorted VPN connection (using F5 Big IP) while most of my dev work/meetings/emailing/etc takes place on my comfortable personal desktop. Working on the work laptop is a miserable affair, it has a tiny, low-res, TNT, 12" panel while my personal PC has two 27" displays.

I would very much like, on the personal PC, to be able to use a dedicated browser plugged into an ssh tunnel running on the laptop to access work-network only apps and to ssh into work machines.

Both machines are running Windows 10, which is fine for my personal PC as all my dev work takes place through WSL2/Docker but is really painful on the work laptop because it's a pre-WSL2 version.

Both PCs use my home wifi connection, through which the work laptop connects to the VPN.

I'm wondering how to go about achieving that ssh tunnel to the work laptop since, once connected to the work VPN, the laptop isn't visible anymore on the local network.

I've been thinking of trying to hook them up via ethernet and use that second connection as the support for the ssh access but I'm not sure that'd work or how to go about it.

Any help would be much appreciated, thank you for taking the time to read this.


Solution

  • Setup a Reverse SSH Tunnel

    In short you connect from your laptop to your Windows10 Box using ssh.. (You will need to run sshd on Windows 10) either via Windows or via cygwin or a virtual machine. Once you have that working you can use the OpenSSH "Reverse tunnel" feature which binds a port on your Windows Box and when your connect to it that opens a connection to your Laptop.

    This example uses port 22 but you could use any TCP based port. (e.g. 3389 is RDP)

    Let's assume that Destination's IP is 192.168.20.55 Laptop that you want to access). You want to access from Windows10 desktop with IP 138.47.99.99. Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99)

    1. SSH from the destination to the source (with public IP) using the command below:

      ssh -R 19999:localhost:22 [email protected]

      • port 19999 can be any unused port.
    2. Now you can SSH from source to destination through SSH tunneling: ssh localhost -p 19999

    3. 3rd party servers can also access 192.168.20.55 through Destination (138.47.99.99). Destination (192.168.20.55) <- |NAT| <- Source (138.47.99.99) <- Bob's server