Check a Linux desktop from Windows or Linux with VNC

Published by TheJoe on

Estimated reading time: 4 minutes


This article was published more than a year ago, there may have been developments.
Please take this into account.

In today's post we see how access to a desktop GNU / Linux (which we will call “server”) da un pc GNU/Linux o Windows (which we will call “client”) with VNC. For today's article, I draw inspiration from an interesting post in English.

Log in to a desktop GNU / Linux from a any other system, located in a anywhere (LAN, internet) using VNC is relatively simple. The result can be obtained regardless of operating system used (GNU/Linux, Windows the Mac OS X). One of the most interesting features is that this procedure can be implemented in a free with a small expenditure of time and without being experts.

There are three essential components to establish a connection with a VNC “desktop environment” (come WHERE the Gnome) su Linux:

  1. the package VNC Server installed on the server machine,
  2. the package VNC Viewer installed on the client that will display the remote computer,
  3. a connessione secure shell (ssh) in both machines.

Get packages “VNC Server” and “VNC Viewer”

There are several ways to get VNC, some “free“, others less “free“. First check that VNC is not already installed on the Linux server. The most recent release of some Linux distro (come Fedora, the RedHat) already include VNC.

[user@localhost ~] rpm -qa|grep vnc

If VNC is already installed the command return some packages, otherwise there will be no output.

In case it was not yet installed VNC, I recommend the use of a modified package of VNC, called “TightVNC“. It can be downloaded from the official site.

Once installed we will have to specify a VNC password to protect access to your computer by strangers. To set the password type the command:

[user@localhost ~] vncpasswd

and insert a sufficiently valid password (suggest that at least 8 characters, with tiny, case, numbers and symbols). Let us remember that the choice of password is a step a lot of important. If your password was deciphered l '”guest” would have the full access to all functions of the machine.

Start and stop the VNC Server

Per l’start VNC Server simply type this command:

[user@localhost ~] vncserver

If there were problems, the output message will look like this:

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 information contained herein demonstrate that vncserver is started on display “:1“, System “myhost“. Ha poi created a subdirectory called hidden “.vnc” the home of the user who invoked. Tale directory contains the scrip startup called “xstartup“. Addition, he has also created a log file.

To stop VNC Server by typing the following command:

[user@localhost ~] vncserver-kill :1

Obviously the words “:1” will refer to the display we want to finish. The output will look like this:

Killing Xvnc process ID 15609

Configure the “Desktop Environment” (WHERE, Gnome, etc..) to be launched by VNC

The next step is to configure “whatto start when you start the VNC Server. As mentioned a few lines ago, when vncserver is started for the first time a directory is created “.vnc” inside the home of the caster. Now modify the file xstartup” in the directory “.vnc” with an editor (gedit, nano, vim, etc..). For simplicity, seen that this guide does not address explicitly the professionals, we will use gedit.

[user@localhost ~] gedit /home/<user>/.vnc / xstartup

The file should look something like this:


# Uncomment the following two lines for normal desktop:
# 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 &

In short this script automatically launches the window manager “twm” (last line), un window manager molto light and qualitatively good. Another good choice is Motif Window Manager (mwm).

Look here:  6 indispensable tools to secure your Linux server

Another option instead, is launch the desktop environment WHERE the Gnome. You can do this directly from the script by changing the last line “twm &” with “gnome-session &“:

Similarly, you can start with KDE “startkde &“.

Install the VNC Viewer (client)

Su Linux (and Unix systems) the VNC viewer is called with little effort of imagination “vncviewer”. If it is not already installed on your system, still recommend the use of “TightVNC“.

Establish a connection “Secure Shell” (ssh) from the due sistemi

For safety reasons it is recommended to always use VNC through an encrypted connection. Con Linux l’ssh is very simple, with Windows, you must use an external program (eg PuTTY).

By default VNC Server communicates over port 59xx, where “xx” represent the number of display (“01” in the case of the first). For example, if vncserver announced that it has started the display “:1” the door will be the 5901.

Suppose you have started on the VNC display “:1” on a system called “myhost“, and we want to establish an ssh connection. The command will be as follows:


[user@localhost ~] ssh-L 5901:localhost:5901 myhost

Con Windows attraverso PuTTY:

  1. start PuTTY, enter the IP or host name of the machine to which we will connect (in our example “myhost“),
  2. select the tab “SSH“,
  3. select option “Tunnels” in “Category list” and enter the following information:
    • Source port: 5901
    • Destination: myhost:5901
  4. save this profile inserted by selecting “Session” from “Category list“, by entering the name in the text field “Saved Sessions” and press “Save“,
  5. press the button Open” to establish the connection ssh.

In both cases, Linux and Windows require the insertion of a password set on the server.

Start the VNC Client

If everything went as it should with the’installation of VNC Server and we have established an ssh connection using the appropriate port, it is now possible launch the VNC Viewer. In Linux the command to run is as follows:

[user@localhost ~] vncviewer localhost:1

In Windows , using TightVNC simply launch the viewer and insert “localhost:1” in the dialog box.

In both cases will be prompted for a password, that set on the server. After a short delay a window containing the Linux desktop should appear. You can now interact with that window just as if we were in front of the console.


I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.


Q. · 19 October 2018 at 11:22 AM

Salve, lei's’ the first for which I disabled adblock.
(that mania to ask e-mail address and website, uff!)

    TheJoe · 19 October 2018 at 12:15 PM

    And I am grateful. Actually enter the web site is not indispensable and that the email is only to receive notifications when someone responds to your comment, as in this case… But since the email you have entered is completely fictitious never gets anything.
    I hope to see you again soon on these pages.

Piriponzolo · 26 May 2017 at 9:56 PM

Salve! And how to access, Unlike, to a desktop Windows XP (which we will call “server”) da un pc GNU/Linux (which we will call “client”) with VNC?

    TheJoe · 30 May 2017 at 6:38 PM

    The procedure is very similar. Once you install VNC server on windows make the call from linux client and proceed as explained in.

Roman · 28 November 2014 at 11:33 AM

Finally a guide that was looking for, I was really useful, thanks!

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.