Installation and configuration of VNC

Source: Internet
Author: User

Virtual Network Computing (VNC) is a desktop sharing system. Its function is similar to the Remote Desktop function in windows. VNC uses the RFB (remote frame buffer, remote frame buffer) Protocol to remotely control another computer. It sends keyboard and mouse actions to the remote computer and sends the screen of the remote computer back to the local computer. The following describes how to install and configure VNC:

 

# Step 1:Run the following command to check whether the VNC client and server have been installed in your system:

[[Email protected] tchung] $ rpm-Q VNC

If the following statement appears, go to # Step 4. If it does not appear, it is executed sequentially.
VNC-Server
Vnc-4.0-0.beta4.3.2
Vnc-server-4.0-0.beta4.3.2
[[Email protected] tchung] $

If the machine does not have a graphical interface installed, install it online first! The password is as follows: (prerequisite: access to the Internet)
[[Email protected] ~] # Yum groupinstall "GNOME Desktop Environment"

# Step 2:Prepare a VNC package

(Find two such packages under the Server Directory of the operating system installation disk, or go to the VNC official website http://www.realvnc.com/download the corresponding vncsoftware Version)
Prepare two packages:

Vnc-4.1.2-9.el5.i386.rpm or vnc-4.1.2-14.el5.i386.rpm

Vnc-server-4.1.2-9.el5.i386.rpm or vnc-server-4.1.2-14.el5.i386.rpm

 

# Step 3:Install the VNC package

Enter the root user, CD to the storage path of the two packages, and perform the following operations:

# Rpm-IVH vnc-4.1.2-9.el5.i386.rpm

# Rpm-IVH vnc-server-4.1.2-9.el5.i386.rpm

Or a # rpm-IVH vnc-E4_4_3-x86_linux.rpm
# Rpm-uvh vnc-E4_4_3-x86_linux.rpm

(If the VNC has been installed on the server, use this command to upgrade the installation)
If the downloaded Enterprise Edition is used, enter the serial number for normal use.
# Vnclicense-add XXXXX-XXXXX-XXXXX-XXXXX-XXXXX (input serial number)

# Step 4:Configuration File

# Vi/etc/sysconfig/vncservers -- Add the following lines, save and exit

Set three users: Root, cheny, and yesd.

Vncservers = "1: Root 2: cheny 3: yesd" (the resolution can be left blank by default in the following settings)

Vncserverargs [1] = "-geometry 1024x768-alwaysshared-depth 16"

Vncserverargs [2] = "-geometry 1024x768-alwaysshared-depth 16"

Vncserverargs [3] = "-geometry 1024x768-alwaysshared-depth 16"

 

-Alwaysshared indicates that multiple terminals are allowed to log on at the same time, and-depth indicates the color resolution, which can be 8, 16, 24, and 32.

 

# Step 5:(Run vncserver one by one. It completes two tasks:

1. Create a required. VNC folder for the user;

2. Set the user's logon password (vncpasswd for password modification)

The default Console mode is used in the system Remote Desktop. To use the image interface, you need to activate unset session_manager and exec/etc/X11/xinit/xinitrc .)

 

1,Start VNC Server (Root User)

Enter the vncserver. The verification password is required for the first startup. Then, the VNC server starts.

[[Email protected] ~] # Vncserver

Write: You will require a password to access your tops
Password: // enter the password
Verify: // enter the password again
Xauth: creating new authority file/root/. Xauthority
New 'localhost. localdomain: 1 (Root) 'desktop is localhost. localdomain: 1
Creating default startup script/root/. VNC/xstartup
Starting applications specified in/root/. VNC/xstartup
Log File is/root/. VNC/localhost. localdomain: 1.log
[[Email protected] ~] #

2, Edit.VNC/xstartup

CD.. CD username CD. vnc vi xstartup
Use VI to open the xstartup file, as shown below:

Activation image interface:

Unset session_manager

Exec/etc/X11/xinit/xinitrc

Comment out the remaining lines.

#! /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 gray
# Vncconfig-iconic &
# Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "&
# Gnome-session &

# Kdestart &
# TWM &

You do not need to comment out all the sections starting from the line below exec/etc/X11/xinit/xinitrc. From the perspective of shell sripts, it is only the test file existence and attribute settings, and the subsequent part is the parameter set to TWM desktop. Therefore, you only need to ensure
Unset session_manager
Exec/etc/X11/xinit/xinitrc
The two rows are not commented out. After this setting, the desktop is displayed as the default desktop logon environment for xwindows. For example, if you set the logon environment to GNOME desktop, the remote connection is GNOME Desktop. If you want to change the desktop environment. You can comment out all the rows in xstartup and add startkde & at the end. You can use KDE to replace TWM. The speed will be slower, but it is much more convenient to use, you can also use gnome-session & to start gnome.


Cheny is the same as other users.

All users who need to use remote desktop are modified using the preceding method.

To switch to another user, run the following command:

Su

Su-username (Su-cheny.

2,Restart VNC Server

Disable the VNC Server Service (you can also set some advanced settings)

[[Email protected] ~] # Vncserver-kill: 1 (there is a space between kill and: 1)

Killing xvnc process ID 21198.

[[Email protected] ~] # Vncserver

New 'localhost. localdomain: 1 (Root) 'desktop is localhost. localdomain: 1
Starting applications specified in/root/. VNC/xstartup
Log File is/root/. VNC/localhost. localdomain: 1.log
[[Email protected] ~] #

VncserverStart and Stop
Start #/sbin/service vncserver start
Disable #/sbin/service vncserver stop

 

# Step 6ViewVNCListening port

As follows, VNC uses three ports: 5801, 5901, and 6001.

[[Email protected]/] # netstat-Nat

Wrote:
Active Internet connections (servers and established)
PROTO Recv-Q send-Q local address foreign address State
TCP 0 0 127.0.0.1: 2208 0.0.0.0: * listen
TCP 0 0 0.0.0.0: 5801 0.0.0.0: * listen
TCP 0 0 0.0.0.0: 5901 0.0.0.0: * listen
TCP 0 0 0.0.0.0: 111 0.0.0.0: * listen
TCP 0 0 0.0.0.0: 6001 0.0.0.0: * listen
TCP 0 0 0.0.0.0: 724 0.0.0.0: * listen
TCP 0 0 127.0.0.1: 631 0.0.0.0: * listen
TCP 0 0 127.0.0.1: 2207 0.0.0.0: * listen
TCP 0 0 172.200.102.3: 5901 181.181.181.51: 1669 established
TCP 0 0: 6001: * listen
TCP 0 0: 22: * listen
TCP 0 1364: FFFF: 172.200.102.3: 22: FFFF: 181.181.51: 1599 established
[[Email protected]/] #

# Step 7:Open the above three ports used by VNC on the firewall
Modify/etc/sysconfig/iptables with root permission

[[Email protected]/] # cd/etc/sysconfig

[[Email protected] sysconfig] # vi iptables

After it is opened, it is changed to the same as the following
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
: RH-Firewall-1-INPUT-[0: 0]
-A input-J RH-Firewall-1-INPUT
-A forward-J RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT-I lo-J accept
-A RH-Firewall-1-INPUT-I eth0-J accept
-A RH-Firewall-1-INPUT-p icmp -- ICMP-type any-J accept
-An RH-Firewall-1-INPUT-P 50-J accept
-An RH-Firewall-1-INPUT-P 51-J accept
-A RH-Firewall-1-INPUT-p udp -- dport 5353-D 224.0.0.20.- J accept
-A RH-Firewall-1-INPUT-p udp-m udp -- dport 631-J accept
-A RH-Firewall-1-INPUT-p tcp-m tcp -- dport 631-J accept
-A RH-Firewall-1-INPUT-M state -- State established, related-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5901-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5902-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5903-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5904-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5905-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5906-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5907-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5908-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5909-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5910-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5911-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 5912-J accept
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 22-J accept
-A RH-Firewall-1-INPUT-J reject -- reject-with ICMP-host-prohibited
Commit

Note that the red part is newly added!

 

Restart iptables:
[[Email protected] sysconfig] #/etc/rc. d/init. d/iptables restart

Wrote:

Flushing firewall rules: [OK]
Setting chains to policy accept: Filter [OK]
Unloading iptables modules: [OK]
Applying iptables firewall rules: [OK]
(Loading additional iptables modules: ip_conntrack_netbios_ns ip_conntrack_ftp [OK])
[[Email protected] sysconfig] #

 

# Step 8:Set auto-start

Enter ntsysv as the root user and select vncserver (Space) in the boot item. Press the tab key to save the settings.

 

VNC Server VNC ViewerLogin

Use VNC Viewer to connect to VNC Server
Download the VNC Viewer and run it. Then, enter the IP: port number, and the password you just set to enter the RedHat desktop.

Note: If you access VNC through web in a browser, the port is 5801. If you access VNC through a VNC client (such as VNC Viewer), the port is 5901.

Installation and configuration of VNC

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.