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:
- the package VNC Server installed on the server machine,
- the package VNC Viewer installed on the client that will display the remote computer,
- 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.
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 “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 “
Similarly, you can start with KDE “
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:
- start PuTTY, enter the IP or host name of the machine to which we will connect (in our example “myhost“),
- select the tab “SSH“,
- select option “Tunnels” in “Category list” and enter the following information:
- Source port: 5901
- Destination: myhost:5901
- save this profile inserted by selecting “Session” from “Category list“, by entering the name in the text field “Saved Sessions” and press “Save“,
- 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.