Connect to a running/existing X session remotely

From the computer you want to view the remote X session:

ssh root@computer2 -L 5900:localhost:5900

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


vncviewer localhost

This is very useful, but make sure you use a password if port 5900 is open on computer2.