How to connect to remote X-Server (logged in via ssh)
I found the problem. Setting DISPLAY manually to localhost:0 is not working, because the XServer does not listen to TCP connections (default Ubuntu 10.04 configuration).
However, setting
export DISPLAY=:0
does the trick.
You will need to set your display environment variable in the ssh session. Most likely, the X server is running on display 0. So in the ssh session (assuming a Bourne-like shell), type:
export DISPLAY=localhost:0
xclock
You should see the clock on the remote X server display.
Note: this should "just work" if your ssh session is logged in as the same user that started the desktop session on the X server. If you are logged in as a different user, you may need to obtain the xauth cookie from the desktop session's user account.
If you are using the command line ssh, and assuming you are using Linux:
ssh -X host
Then try something like:
xclock
And you should see a clock but it is being ran on the remote computer.
Note: This will only work if x forwarding is turned on in the sshd config file.
Of course this is just a quick overview - can you post more info like what OS you have and what SSH client you are using?