I need to connect via VNC from my machine A to another machine belonging to my friend B. Both of us have no way to open incoming ports - ISPs do not allow tunneling unless you buy a static IP based business plan. Both are linux systems BTW

We have a web server with full access, where we can both ssh into. How do we setup a tunnel from either end to teh server so that VNC works?

I know how to setup an ssh tunnel between two systems and I believe its not hard to do A->B->C by running ssh first on A to B and then on B to C

But I need A->C and B->C rather than A->B and B->C

Basically I think I need a proxy server - can this be done with SSH or even some sort of linux networking magic?


Let's say C is the webserver that you both (A: You & B: Your friend) have access to.

Setup for C: Add gatewayports yes to the config

vim /etc/ssh/sshd_config

add "GatewayPorts yes" at the bottom so the remote host will listen on the interface instead of the interface

GatewayPorts yes

Setup for B: Forward localhost's "port2" to remote host's (C) "port1"

ssh -i auth.pem -R xxx@xxx.xxx.xxx

Setup for A: No need for forwarding.

You can now connect to C's port2 using VNC while actually viewing B's screen.

  • Thanks - this worked – rep_movsd Apr 20 '20 at 16:50

This may or may not be the answer you're looking for, but two services to check out:

They do roughly the same thing. Both allow you to create virtual private networks between multiple computers without needing to do any firewall or port forwarding configuration. Both services have a free tier, although if you need lots of computers connected, ZeroTier allows more computers on their free version. Both work on Linux, Windows and Mac OS (ZeroTier works on a bunch of other platforms too).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.