I found this somewhere online and found it very useful. If you ever need to enable or disable remote desktop via a remote connection like ssh here’s how to do it below. This is useful if you do not have physical access to a machine which is very common.
To enable remote desktop use this command:
gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true
To disable remote desktop use this command:
gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled false
Simple as that!