From the computer you want to view the remote X session:
ssh [email protected] -L 5900:localhost:5900
If you can only connect to a linux gateway, you can substitute localhost with the internal IP address of the machine you want to vnc to.
ssh [email protected] -L 5900:192.168.1.100:5900
On computer2 do the following.
This does not need to be done as root, but you’ll need to be the actual user running the X session if you log in as a regular user. On ubuntu/debian you can use apt-get install x11vnc.
x11vnc -display :0 -passwd password
If it complains that it cannot connect to :0, try this
x11vnc -auth /var/lib/gdm/:0.Xauth -passwd password
Note that using the :0.Xauth method will work if X is just running at the login screen (so you could connect and log into X as a user).
Now, from computer1, do
This is very useful, but make sure you use a password if port 5900 is open on computer2.