Vnc Remote Desktop Server Configuration tutorial in Linux

Source: Internet
Author: User
VNC is short for VirtualNetworkComputing. VNC is an excellent cross-platform remote desktop control software developed by AT & amp; T's European research laboratory. it supports cross-platform remote desktop control for Linux, Unix, Windows, and other operating systems. VNC consists of two parts: Server (vncserver)

VNC is short for Virtual Network Computing. VNC is an excellent cross-platform remote desktop control software developed by AT&T's European research laboratory. it supports cross-platform remote desktop control for Linux, Unix, and Windows operating systems. VNC consists of two parts: the server (vncserver) and the client (vncviewer ). The following describes how to install, configure, and use VNC on Linux (VNC server) and Windows (VNC client.

Lab environment
VNC server:
Operating system: Red Hat Enterprise Linux AS 5
Kernel version: 2.6.18-8. el5
CPU architecture: i386 SMP
Attachment software: Red Hat Enterprise Linux AS 5 DVD installation disk
VNC client:
Operating system: Windows Server 2008 Enterprise
Browser: Windows Internet Explorer 7

1. install VNC in Linux
Add the Red Hat Enterprise Linux AS 5 DVD installation disk to the DVD drive and run the following command to install it:


# Mkdir-p/mnt/cdrom: http://www.aiezu.com # mount-t auto/dev/cdrom/mnt/cdrom # cd/mnt/cdrom/Server # rpm-ivh vnc-server-4.1.2-9.el5.i386.rpm # rpm-ivh vnc-4.1.2-9.el5.i386.rpm article to [Love e]: http://www.aiezu.com
2. configure the VNC Server in Linux
①. Introduction to the running mechanism of VNC:
Before configuring VNC, you must understand the running mechanism of VNC. In Linux, VNC can start multiple vncservers at the same time. each vncserver is differentiated by the display number. each vncserver listens to three ports, which are:
5800 + display number: httpd listening port of VNC. it must be enabled if the VNC client is IE or Firefox or other non-vncviewer.
5900 + display number: the real port used for communication between the VNC server and the client, which must be opened unconditionally.
6000 + display number: X listening port, optional.
The displayed numbers and open ports are controlled by vncservers and VNCSERVERARGS in the/etc/sysconfig/VNCSERVERS file. VNCSERVERS is set as "VNCSERVERS =" display ID 1: User name 1... "", Such as: VNCSERVERS = "1: root 2: aiezu ". VNCSERVERARGS is set as VNCSERVERARGS [Display ID 1] = "parameter 1 parameter value 1 parameter 2 parameter value 2 ...... ", Such as VNCSERVERARGS [2] ="-geometry 800x600-nohttpd ", detailed VNCSERVERARGS parameters include:

-Geometry desktop resolution. the default value is 1024x768;
-Nohttpd does not listen to HTTP port (58xx port );
-Nolisten tcp does not listen to Port X (Port 60xx );
-Localhost can only be accessed from the local machine;
-AlwaysShared only allows one vncviewer connection by default. This parameter allows multiple vncviewer connections at the same time;
-SecurityTypes: password authentication is not required for non-logon of SecurityTypes. the default value is VncAuth. password authentication is required.

②. Modify the/etc/sysconfig/vncserver file:
After familiarizing yourself with the running mechanism of VNC in Linux, you can officially configure the VNC Server. Vi/etc/sysconfig/vncserver, add the following three lines: article to [love eFamily]: http://www.aiezu.com

VNCSERVERS = "1: root 3: aiezu "VNCSERVERARGS [1] ="-geometry 800x600-nolisten tcp "VNCSERVERARGS [3] ="-geometry 1024x768-nolisten tcp "in this example, we start two vncservers, it is the root user, and the display number is 1 and the user aiezu, and the display number is 3, and no x listening port 60xx is enabled.

3. set the VNC user password:
Next, set the VNC password. this step cannot be skipped. Otherwise, the VNC Server cannot be started. run the following command in Linux Shell:

# Su-aiezu # vncpasswd Password: article to [love eFamily]: http://www.aiezu.comVerify: # su-root # vncpasswd Password: Verify: service vncserver start // start vncserver after running the above command, under the user root directory ($ HOME ". A series of files are generated under the vnc folder. Passwd is the vnc user password file generated by vncpasswd. Other scripts are generated when vnc is started for the first time and xstartup is the script started when the VNC client is connected. Article to [Love E family]: http://www.aiezu.com

④. Modify the ". vnc/xstartup" file:
After performing the preceding steps, the VNC Server can run properly. However, xterm is enabled when the client connects to the desktop by default ". comment out the last two lines in the vnc/xstartup file, and add a line "startkde &" or "gnome-session &" based on the desktop environment you have installed &". As follows:

#! /Bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec/etc/X11/xinit/xinitrc to [love e]: http://www.aiezu.com [-x/etc/vnc/xstartup] & exec/etc/vnc/xstartup [-r $ HOME /. xresources] & xrdb $ HOME /. xresources xsetroot-solid gray vncconfig-iconic & # xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop" & # twm & articles to [ee]: http://www.aiezu.comstartkde & # Gnome-session & after ". vnc/xstartup" under the root directory of each user is configured, run service vncserver restart to restart vncserver to make the configuration take effect.
⑤ Configure the firewall:
If the firewall is enabled in Linux, the VNC ports (58xx, 59xx, 60xx) must be allowed ). For details about the specific port, refer to the VNC running mechanism in step 1 of step 1. in this example, enable the ports 5801,5803 and 5901,5903. Enter "system-config-securitylevel-tui" at the Linux command prompt to start the firewall configuration tool. click "Customize" and enter "5801: tcp 5803:" in "Other Port: tcp 5901: tcp 5903: tcp ", and click" OK.
Article to [Love E family]: http://www.aiezu.com
3. VNC client configuration and connection
① Use IE for remote control connection in windows:
When using a browser to connect, the VNCSERVERARGS settings of the server must not have the "-nohttpd parameter", and the firewall allows the 58xx and 59xx ports of the VNC to pass through. The browser must have the Java support plug-in installed, Java plug-in: http://www.java.com/zh_CN/download/manual.jsp
②. Use vncviewer to remotely control the connection in windows:
Using vncviewer for remote control is the easiest way. you only need to enable the "59xx" port on the server. The client does not need to be configured. after double-clicking vncviewer, enter the IP address and port of vncserver in the server text box (in this example, 192.168.1.22: 5901 ). Local vncviewer green edition: http://www.aiezu.com/soft/vnc-4_1_2-x86_win32_viewer.exe
③ Use vncviewer for remote control connection in Linux:
The vnc-4.1.2-9.el5.i386.rpm package must be installed before you use vncviewer, which is used as: vncviewer host: Display number.
④. Use vncviewer1_putty.exe in Windows to connect through the ssh Secure Channel:
Open putty and click "Connection"-> "SSH"-> "Tunnels" in the "Category" on the left ". In the "Source Port" text box, enter "5901", "Destination" text box, enter "localhost: 5901", and click "Add" to Add Port forwarding. Click "Session" under "Category" on the left of putty, enter the IP address of the server, click "Open", and enter the password to log in. port forwarding is enabled successfully. Start vncviewer on the local machine and enter "127.0.0.1: 5901" to connect to the remote port 5901.
⑤ Use vncviewer + ssh secure channel connection in Linux:
Similarly, run the "ssh-L 5901: localhost: 5901 vncserverhost" command in the shell of the linux vnc client and enter the user name and password. That is, the remote port 5901 is forwarded to the local port 5901 through the shh security channel. Then run the "vncviewer 127.0.0.1: 1" command in shell to connect to the remote VNC Server.
In the above five connection modes, the data in the first three modes is transmitted in unencrypted form on the network, which is extremely insecure and is not recommended. Article to [Love E family]: http://www.aiezu.com

4. FAQs
①. Q: Why is the desktop not displayed after the connection is successful, but a real Terminal window?
①. A: in the. vnc/xstartup file under the root directory of the user, the default setting of xstartup is the case. Modify xstartup in step 2 of step 2, and then run "service vncserver restart" to restart the vncserver service.
②. Q: How do I view the port number of the VNC running display number?
①. A: Run "netstat-tlup | grep vnc" at the Linux command prompt to view the port number. the last two digits of the port number are displayed.
③. Q: How do I disable the specified display number? Article to [Love E family]: http://www.aiezu.com
①. Answer: vncserver-kill: number indicates that the specified display number and corresponding port number can be disabled.
④. Q: Why does the browser display a red cross when I connect to the VNC port through a browser.
①. A: That's because your browser has not installed the Java plug-in. download and install the Java plug-in.
⑤. Q: What is the "Connetcion timed out (10060)" during client connection?
①. A: If "Connetcion timed out (10060)" or "No route to host: connect" appears during client connection, check whether 58xx, 59xx, and vncserver are enabled on the firewall, and whether the/etc/sysconfig/vncserver file is correctly configured.
6. Q: "Error: Cant open display: 0.0" Error occurs when an X application is started on the GUI desktop connected by VNC?
①. A: run the "echo $ DISPLAY" command to check whether the "DISPLAY" environment variable is set to ": DISPLAY No.: 0", for example, ": 1: 0 ". If not, this error occurs when X application is started. In this case, you can use "export DISPLAY =: 1: 0" to set the correct DISPLAY. Another possibility is to switch the user to start the X application. the current user does not have the permission to use the X Window. then, the user who has enabled VNC is returned, run "xhost +" to allow other users to access this X Window.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.