How to Remotely Display and Control a Linux Desktop
Transcript of How to Remotely Display and Control a Linux Desktop
-
7/28/2019 How to Remotely Display and Control a Linux Desktop
1/4
How to remotely display and control a Linux desktop from a Windows
or Linux system using VNC
It is relatively straightforward to display and access a Linux desktop from a system anywhere else on a network or
the internet by using Virtual Network Computing (VNC). This can be achieved regardless of whether, for
example, that system is running Linux, Windows or Mac OS X.. The even more impressive thing about this is that
it can be set up for free with only a little time and knowledge.
There are three key areas to establish a VNC connection to a desktop environment (such as KDE or GNOME) on
your Linux system:
1. A VNC server installed and running on your Linux system.
2. A VNC viewer client installed on the system on which you want to display your Linux desktop.
3. A secure shell (ssh) connection between the two systems.
In this VNC How To Guide we will take you step by step through the process and have you driving the Linux
desktop home or office Linux system while you sit drinking coffee infront of a Windows laptop in your local
WiFi-enabled Starbucks.
Obtaining a VNC Server and Client
There are a number of ways to get VNC - some free and some not so free. First check that VNC is not already
installed on your Linux system. Most recent releases of Linux such as Redhat Linux and Fedora Core will come
with VNC rpms on the installation CDs.
If you do not already have VNC then we recommend TightVNC which can be obtained for free from:
http://www.tightvnc.com/download.html
Once you have VNC installed you will need to specify a password to protect access to the VNC server. To do this
run:
vncpasswd
and enter a suitable password.
Starting and Stopping the VNC Server
The next thing you need to learn how to do is start and stop the VNC server. Start the VNC Server with the
following command:
vncserver
http://www.tightvnc.com/download.htmlhttp://www.tightvnc.com/download.html -
7/28/2019 How to Remotely Display and Control a Linux Desktop
2/4
Assuming no problems are encountered vncserver will output a message that looks something like:
New 'myhost:1 (src)' desktop is myhost:1
Creating default startup script /home/neil/.vnc/xstartup
Starting applications specified in /home/neil/.vnc/xstartup
Log file is /home/neil/.vnc/myhost:1.log
The key information here is that vncserver has started up an X server as display :1 on system "myhost" and that it
has created a sub-directory called .vnc in the home directory of the user that started the server containing a startup
script called xstartup. In addition it has also created a log file that can be reviewed to diagnose any problems
should the server have failed to start.
To stop the VNC server simpy run the following command:
vncserver -kill :1
where the :1 matches the display that was indicated when vncsever started up. This will display something alongthe lines of:
Killing Xvnc process ID 15609
A useful point to note here is that process being killed in called Xvnc. Xvnc is the the actual VNC server process.
The vncserver command we ran to launch the VNC server is actually a shell script that sets up the environment
prior to launching the Xvnc process.
Configuring the Desktop Environment to be Launched by VNC
The next step is to configure what gets started up when the VNC server is launched. As outlined previously the
first time a user starts vncserver the .vnc directory is created in their home directory. Change directory to
$HOME/.vnc and load the xstartup file into an editor. It should appear as follows:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
These commands perform some basic tasks such as setting the background of the X window, launching an X
-
7/28/2019 How to Remotely Display and Control a Linux Desktop
3/4
terminal window and finally launching the twm window manager. The twm window manager is a very good
lightweight window manager. Another good lightweight manager is the Motif Window Manager (mwm). Those
familiar with the Common Desktop Environment (CDE) on Solaris, HP and IBM systems may want to change to
the "twm &" to "mwm &" in the xstartup script.
Another option is to launch the GNOME or KDE desktop environments. To launch the GNOME desktop
environment change the twm line in xstartup to:
gnome-session &
Similarly to launch the KDE desptop environment change the line to:
startkde &
Feel free to add other commands to the xstartup script. For example if you would like your favorite mail tool or
development IDE to launch automatically then xstartup is the place to do it.
Installing the VNC Viewer Client
Having selected the desktop environment you would like to use the next step is to install the client side VNC
viewer. On Linux and Unix systems the viewer is called vncviewer. Check to see if you already have VNC
installed on the client system. If it is not already installed or you are running on Windows we once again
recommend that you download TightVNC from:
http://www.tightvnc.com/download.html
Establishing a Secure Shell connection between the two systems
For security reasons it is recommended that the VNC communication take place through an encrypted secure
tunnel connection. On Linux or Unix this can be achieved using the ssh command. On Windows we recommend
that you use PuTTYwhich is freely available from:
http://www.putty.nl/download.html
By default the VNC server will communicate on port 59xx where xx represents the display number. Ifvncserver
announces that it is running as display :1 then the port being used is 5901. If it tells you it is display :2 then port
5902 is being used and so on.
Supposing you have the VNC running on display :1 on a system called myhost then you would need to establish a
ssh connection as follows:
Linux:
ssh -L 5901:localhost:5901 myhost
Windows using PuTTY:
-
7/28/2019 How to Remotely Display and Control a Linux Desktop
4/4