Starting an X11 Program Remotely

Have you ever wanted to start a graphical program (X11) remotely on computer?  I found myself wanting to be able to cause a program to open on the physical screen and session on a computer while I was connected to it remotely via SSH.  After some searching online, I found the answer on serverfault.com.  The only problem was it didn’t work on Ubuntu 9.10.  Then I found another blog where the commenters had provided a solution.  It seems that security has been added so this very thing is not usually possible.  But if you want to disable the security temporarily, you can enable the feature again.

After SSHing into the computer, I ran the following commands to disable the security and launch The GIMP as a test.

user@user-desktop:~$ DISPLAY=:0 sudo xhost +
access control disabled, clients can connect from any host
user@user-desktop:~$ DISPLAY=:0 gimp
I confirmed that GIMP launched on the actual session running.
Alternatively, there may be occasions when you actually want to launch a graphical program on the connecting computer remotely over SSH.  That is also possible via the -X command line option when initiating the SSH connection.  Then all program you start will be forwarded to the local X windows server and will be rendered locally.
ssh -X user@server
gimp
You probably want to be on a very fast connection, such as a local network to get the best experience using this, because it can be very slow.