0

I mostly have Unix devices and use VNC through SSH to connect to all of them. However I have one Windows 10 PC and I cannot remote into it.

On the Windows 10 PC, I installed TightVNC Server (Version 2.8.63), listening on port 5900. I can successfully VNC to it without SSH.

I also set up OpenSSH on the Windows PC. It listens on port 22002. I can SSH successfully SSH into the PC.

Next I build the tunnel from my Unix device, with ssh -L 5901:localhost:5900 [email protected] -p 22002. The tunnel successfully builds. I next try to establish the VNC session from my Unix device, connecting to localhost:5901. This is where it fails, I get the response:

Connection failed to "localhost". Unable to communicate with "localhost". Make sure the remote computer is available and the firewall is not blocking screen sharing.

Connection Error Message

Things I've tried:

  • Disabling all firewalls on the Windows PC, to be sure
  • Enabling 'Allow Loopback Connections' in TightVNC preferences
  • In the sshd_config file, I set 'GatewayPorts yes', 'PermitTunnel yes', and 'AllowStreamLocalForwarding yes'

Any other ideas??

4
  • 1
    Have you try with hostname or IP instead of localhost? Commented Jul 17, 2022 at 14:27
  • I haven’t and can try later, however I use localhost:5901 when tunneling into other Unix hosts. So I suspect the config issue is on the server (Windows) side.
    – Junto026
    Commented Jul 18, 2022 at 16:13
  • 1
    Oh you might be saying to change localhost in the SSH command… I will definitely try that and report back.
    – Junto026
    Commented Jul 18, 2022 at 16:16
  • 1
    That was it! Instead of building the SSH tunnel with ssh -L 5901:localhost:5900 [email protected] -p 22002 I need to build the SSH tunnel with ssh -L 5901:127.0.0.1:6900 [email protected] -p 22002. Not sure why Windows doesn't like localhost there, but it's working now. Thank you!
    – Junto026
    Commented Jul 18, 2022 at 17:55

1 Answer 1

1

Thanks to Romeo Ninov for pointing this out. When building the SSH tunnel to windows, the loopback address needs to be used, not localhost. So instead of:

ssh -L 5901:localhost:5900 [email protected] -p 22002

I needed to use:

ssh -L 5901:127.0.0.1:5900 [email protected] -p 22002

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .