Configuration and use of VNC Server in CentOS

Source: Internet
Author: User

VNC is an excellent remote control tool software developed by the famous AT&T European research laboratory. VNC is a free open-source software based on UNIX and Linux operating systems. It has powerful remote control capabilities and is highly efficient and practical. Its performance can be comparable to any remote control software in Windows and MAC. In Linux, VNC includes the following commands: vncserver, vncviewer, vncpasswd, and vncconnect. In most cases, you only need two Commands: vncserver and vncviewer.


1. Command description vncserver: this service program must be running on a master (or remote control) computer. You can only use this service as a user (without the root user identity.
Vncviewer: A local application used to remotely access a computer running vncserver and display its environment. You need to know the IP address of the remote computer and the password set by the vncserver.
Vncpasswd: password setting tool for vncserver. The vncserver service program cannot run without a password (good habit ). If you have not set the password, it will prompt you to enter a password when running vncserver. Therefore, I usually do not run this command to set the password.
Vncconnect: tells the vncserver to connect to the IP address and port number of a remote computer running vncviewer. In this way, I can avoid giving others a password for access.
Xvnc: a "master" program of vnc, which generally does not need to be run directly. (Vncserver and vncviewer are Xvnc scripts)
Find all available options and run:
Xvnc -- help
For security reasons, it is generally not recommended to run the vncserver program directly with a Super User Account. If you need a Super User Environment, log on to the Super User Account Using the su command.
The workflow for running VNC is as follows:
(1) connect the VNC client to the VNC Server through a browser or VNC Viewer.
(2) The VNC Server sends a dialog window to the client, requiring that you enter the connection password and access the VNC Server display device.
(3) After the client enters the online password, the VNC Server verifies that the client has access permissions.
(4) If the client passes the VNC Server verification, the client requires the VNC Server to display the desktop environment.
(5) The VNC Server uses X Protocol to require X Server to assign control of the display to the VNC Server.
(6) The VNC Server will be sent to the client using the VNC communication protocol in the desktop environment of X Server in the future, and allow the client to control the desktop environment and input device of the VNC Server.

The following installation environment is CentOS6.5.


2. Install VNC

First, check whether VNC is installed on the local machine. By default, CentOS 6.0 is not installed.
Check for installation. Enter:

[root@localhost ~]# rpm -q vnc vnc-server
Get:

package vnc is not installedpackage vnc-server is not installed

If the prompt is not installed, start the installation. Enter:

[root@localhost ~]# yum install vnc vnc-server
Note: For Ubuntu, enter:
[root@localhost ~]# apt-get install vnc vnc-server
The system will prompt you to confirm some options and enter "Y" to confirm.

Set VNC password for the first time

[root@localhost ~]# vncserver

Repeat the input twice.


3. Configure the Desktop
[root@localhost ~]# vi ~/.vnc/xstartup
Modify the last two rows. Changed:

# xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &# twm &gnome-session &
In general, the last two lines of the original configuration file are commented out, and a line of code is added, indicating that the "Gnome" desktop is used.

Save the file.


4. Configure the Logon account

[Root @ localhost ~] # Vi/etc/sysconfig/vncservers

The following prompt is displayed:

# The VNCSERVERS variable is a list of display: user pairs.

## Uncomment the lines below to start a VNC server on display :2# as my 'myusername' (adjust this to your own).  You will also# need to set a VNC password; run 'man vncpasswd' to see how# to do that.## DO NOT RUN THIS SERVICE if your local area network is# untrusted!  For a secure way of using VNC, see this URL:# http://kbase.redhat.com/faq/docs/DOC-7028# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.# Use "-localhost" to prevent remote VNC clients connecting except when# doing so through a secure tunnel.  See the "-via" option in the# `man vncviewer' manual page.# VNCSERVERS="2:myusername"# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

Edit the last two lines and remove the comments of the two lines:

VNCSERVERS="1:root"VNCSERVERARGS[1]="-geometry 1024x768"

If you have multiple accounts, configure them in the following format.

VNCSERVERS = "1: user1 2: user2 3: user3 "VNCSERVERARGS [1] ="-geometry 1024 × 768 "VNCSERVERARGS [2] ="-geometry 1024 × 768 "VNCSERVERARGS [3] ="-geometry 800 × 600-depth 24 -nolisten tcp-nohttpd-localhost "# tcp is not supported, http connections are not supported. access can only be tested locally.

If user2 is used, perform the following operations on user2:

[Root @ localhost ~] # Su user2 [test @ localhost ~] $ Mkdir. vnc // * Create A. vnc directory to save the vnc configuration file * // [test @ localhost ~] $ Vncpasswd // * set the vnc remote connection password of user2 * // [test @ localhost ~] $ Su root [root @ localhost ~] # Service vncserver restart


5. configure the firewall and system services

The VNC server listening port starts from 5900. The display: 1 listening port is 5901, the display: 2 listening port is 5902, and so on. By default, the CentOS firewall does not allow connection to these ports. Therefore, use the following steps to open the Firewall:

[root@localhost ~]# vi /etc/sysconfig/iptables
Only one root account and one desktop 1 are added. Therefore, add a "5901" port according to the above rules.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
Restart the Firewall Service.
Set VNC to start automatically
[root@localhost ~]# chkconfig -level 345 vncserver on

6. Test the VNC connection. Take the windows vncviewer connection as an example:

Enter Password


Expected results




7. Download the installer from the reference and expansion links: Release


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.