Ubuntu – Connecting with vinagre (VNC) through intermediary ssh server

remote desktopsshvinagrevnc

Ok, I cannot seem to get VNC connection to work. I'm not sure if I understand it. So:

I want to connect from my home pc (let's call it athome) to my work desktop (let's call it atwork, but I have to tunnel through a connection server (let's call it workserver).

So can someone explain me how I can use, e.g., Vinagre to connect from athome to atwork via workserver (and share the desktop, which I enabled at atwork vino-preferences)? I can get access them all fine via ssh in the terminal, but I can't get Vinagre to connect.

I've tried with the "Use host … as SSH tunnel" option. It didn't work.

I've tried ssh -v -N -R 5902:atwork:5902 user@workserver in the terminal and then connect to localhost:5902, but it didn't work.

I'm probably doing something wrong, so I would be very happy if someone could explain me clearly how it should be done.

Thanks

Best Answer

I was able to simulate (I hope) your situation, if I understood it.

The need is to connect to a machine atwork's VNC server. atwork is not accessible via ssh from the client machine athome. However, atwork is accessible via ssh from the intermediate machine workserver. workserver is accessible via ssh from athome.

If this is the correct scenario, I was able to connect in a similar situation. I used remmina which by default tries to connect on port 5900. Here is how I did it using intermediate port 5901. Adjust ports as necessary in your situation.

enter image description here

  • Set up first tunnel from athome to workserver.

    ssh -L 5900:localhost:5901 -N -f -l username workserver
    
  • Set up 2nd tunnel from workserver to atwork

    SSH into workserver and enter the next command. Leave this ssh window open.

    ssh -L 5901:localhost:5900 -N -f -l username atwork
    
  • Back on athome, start remmina and connect to localhost

Somewhat to my surprise, it worked.

When done, go back into the workserver ssh window and killall ssh. Then killall ssh on athome.