If you want to access your remote Ubuntu machine with VNC, in particular by tunnelling through ssh, there is already some documentation which can be found here. However, at least for me, the procedure explained there does not work out of the box. So here’s what I had to do to make it work.
First of all you need to install in the machines the following packages:
- remote machine: xvfb x11vnc openssh-server
- local machine: xtightvncviewer openssh-client
Then, the script to run on your client machine to access the server has to be slightly modified as follows
1 2 3 4 5 6 7 |
#!/bin/sh ssh -C -f -L 5900:localhost:5900 USER@REMOTEIP \ x11vnc -safer -localhost -nopw -once \ -auth /home/USER/.Xauthority -display :0 -create \ && sleep 5 \ && vncviewer localhost:0 |
where you will have to replace USER with your user on the remote machine, and REMOTEIP with the address of your remote machine.
Basically, the changes I had to make to the original script were to add the -auth command line option specifying the path to the .Xauthority, and the command line option -create to actually start an instance of the X server on the remote machine.