First, enable Remote Desktop in Gnome by going to System -> Preferences -> Remote Desktop.
Check ‘Allow other users to view your desktop’.
Check ‘Allow other users to control your desktop’.
Uncheck ‘Ask you for confirmation’.
Type in the password you want to use.
Click Close.
Remote Desktop is now running on your machine.
Now, open a terminal and type this command:
$ gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled false
Go back to System -> Preferences -> Remote Desktop. You will see that it is now turned off.
You can turn it back on from the command line using this command:
$ gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true
The reason I find these commands handy is that I like to only turn on Remote Desktop when I actually need to use it. So, after I set up SSH and secure it, I then log into my machine remotely via SSH and run the command to enable Remote Desktop. Once I do that, I can then open up VNC Viewer from the remote machine, and do what I need to do. I then disable Remote Desktop via SSH with the disable command so that the server is no longer available to myself or anyone else that might try to access it.
I have taken this a step further on my machine and simplified this process by creating two bash shell scripts:
startvnc.sh
#!/bin/bash
#
# This script starts enables System -> Preferences -> Remote Desktop
gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true
stopvnc.sh
#!/bin/bash
#
# This script starts enables System -> Preferences -> Remote Desktop
gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled false
After creating those scripts, I make them executable with this command:
$ chmod +x startvnc.sh
$ chmod +x stopvnc.sh
I then make aliases to them. Open ~/.bashrc in a text editor, scroll to the bottom, and type in these two lines:
alias startvnc=/path/to/your/startvnc.sh
alias stopvnc=/path/to/your/stopvnc.sh
Now, when you SSH into your box (or open a command line), you can just type $ startvnc to enable Remote Desktop, or $ stopvnc to disable Remote Desktop.
*Remember, if you are behind a firewall, you have to allow access through port 5900 if you want to Remote Desktop into your default display (:0).
This comment has been removed by a blog administrator.
ReplyDeleteI'm gonna say you why Linux is great that's because the development of Linux is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed, and it has been spread around the world.m10m
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteJust wanted to say thanks for posting this tip! I needed to use SSH to turn on a Remote Desktop of a system whose Desktop I did not have access to so I couldn't do System -> Preferences -> Remote Desktop. I previously used vino-preferences via SSH with X11 forwarding to do it as a window would pop up but I didn't have X11 available this time. I thought I was stuck but your tip saved me.
ReplyDeleteI have question. In RHEL 5.3, I am able to login via SSH, type the gconftool-2 command to turn on Remote Desktop, then type startx to actually start the gnome desktop service for my SSH session (the actual server runs at run level 3). Note the startx command doesn't actually open a desktop window for my SSH session, I then use a VNC viewer to connect to the desktop session which was started with the startx command. Once I close the SSH session which ends my startx command, I can no longer connect via the VNC viewer which is what I want, the remote desktop session was temporary to my SSH session. Hope this makes sense?
I tried this procedure in RHEL 5.6 and the startx from the SSH command line no longer works for starting this temporary remote desktop. So now I'm not sure of how to get a remote desktop short of actually asking someone to login to the physical server and do a startx, but that defeats my purpose of opening a temporary remote desktop connection for myself only. Any ideas? Thanks.
Virtualtech: Enable/Disable Remote Desktop From The Command Line >>>>> Download Now
ReplyDelete>>>>> Download Full
Virtualtech: Enable/Disable Remote Desktop From The Command Line >>>>> Download LINK
>>>>> Download Now
Virtualtech: Enable/Disable Remote Desktop From The Command Line >>>>> Download Full
>>>>> Download LINK