Cookie

TheJoe.it Into the (open) source

20Sep/104

Check a Linux desktop from Windows or Linux with VNC

Caution!

This article was written in the 2010, there may have been some developments in the subject matter.
If in doubt please leave a comment in the bottom of the article.
Thanks.

vncOSXvnc

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, 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

For thestart 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 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 "what" to 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:

#!/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 &

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).

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, recommend the use of still "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. With the Linux '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:

Linux:

[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 entering 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.

About

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.

Comments (4) Trackbacks (0)
  1. 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?

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


Leave a comment

No trackbacks yet.