VNCServer remote desktop configuration in CentOS

Source: Internet
Author: User
PS: In the past, remote graphic desktops in Linux were basically not used. some colleagues developed a few days ago had a problem configuring CentOS vnc. if you solve this problem, let's record and summarize it by the way, this summary is complete. The following configurations are tested and verified in CentOS5.x, 6.x, and SUSE Enterprise versions. other releases are also common: 1. install the corresponding desktop environment and vnc server and client: # yumgroupinstall & quot; GNOMEDesktop & n

PS: In the past, remote graphic desktops in Linux were basically not used. some colleagues developed a few days ago had a problem configuring CentOS vnc. if you solve this problem, let's record and summarize it by the way, this summary is complete. The following configurations are tested and verified in CentOS5.x, 6.x, and SUSE Enterprise versions. other releases are also applicable to the following reasons:

1. install the corresponding desktop environment and vnc server and client:

# Yum groupinstall "GNOME Desktop Environment" (CentOS 5.x install GNOME Desktop Environment)
# Yum groupinstall "X Window System" "Desktop" (CentOS 6.x install GNOME Desktop environment)
# Yum groupinstall Xfce (optional)
# Yum install vnc-server vnc * (in CentOS 5.x)
# Yum install tigervnc-server tigervnc (in CentOS 6.x)


Note: Xfce, KDE, and Gnome are both graphic desktop environments. They are characterized by a smaller resource Occupation: Gnome> KDE> Xfce. The specific situation depends on the version. Generally, the newer the version, the larger the resource usage.

II. VNC startup and restart:
#/Etc/init. d/vncserver restart
Note: Sometimes an error is reported when the preceding command is started. you can run the command directly:
# Vncserver
Note: disable the vncserver command: vncserver-kill: 1 vncserver-kill: 2

3. configure remote logon to gnome desktop:
# Vim/etc/sysconfig/vncservers (this file is not required for SUSE Enterprise Edition)
Add the following two lines at the end:

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

Note:

1.-alwaysshared indicates that multiple users can log on to the same display port simultaneously. The value of-depth indicates the color depth. the parameters include 8, 16, 24, and 32;
2. here the "user name" refers to the name of the linux system user;
3. in the first line of the above three lines, you can set multiple accounts that can use the VNC server, but separate them with spaces. Note the preceding numbers "1" or "2". when you want to come to the VNC server from another computer, you need to use IP Address: 1 instead of IP address. Assume that the IP address of your VNC server is 192.168.1.100. to enter the VNC server and log on as a peter user, enter 192.168.1.100: 1 in vncviewer, if it is root, it is 192.168.1.100: 2;
4. the following two rows [1] [2] are best matched with the above one. The following 800X600 can be replaced with the resolution supported by your computer. Note that the "x" in the middle is not "*", but a lowercase letter "x ".

4. set the vnc access password:
# Vncpasswd
Note: Here is the password for the above root remote user, so it should be configured under the root account; and so on, it is necessary to set a password for another account..

V. modify the remote desktop display configuration file:
# Vim/root/. vnc/xstartup

#!/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" &
gnome-session & #set starting GNOME desktop
#startkde & #kde desktop
#twm & #Text interface
#/usr/bin/startxfce4
#exec /usr/bin/fluxbox


Note:
1. if you do not modify this file, the remote desktop you see is very simple. it is equivalent to a command line operation. to perform remote operations like local operations, you must modify the file by referring to the above methods;
2. as long as you enable VNCserver once, it can be automatically created as follows:
# vncserver
Through the above method, you can create an xstartup file in the. vnc directory under the user's home directory.

VI. vnc client login:
In the vnc client, enter: server IP: 1 or server IP: 2.
:

The iptables firewall blocks the remote desktop of vnc by default. Therefore, you must allow the remote desktop through iptables. After you start the vnc service, you can run the netstat-tunlp command to view the ports used by the vnc service, such as 6001, 5901, and. Run the following command to enable these ports:
# Vim/etc/sysconfig/iptables
Add:
-A rh-Firewall-l-INPUT-p tcp-m tcp-dport 5801-j ACCEPT
-A rh-Firewall-l-INPUT-p tcp-m tcp-dport 5901-j ACCEPT
-A rh-Firewall-l-INPUT-p tcp-m tcp-dport 6001-j ACCEPT
Restart firewall:
#/Etc/init. d/iptables restart
Or close the firewall directly:
#/Etc/init. d/iptables stop

7. start the vncserver service at startup:
# Chkconfig vncserver on

8. vnc reverse connection settings:

In most cases, the vncserver is always listening, and the vnc client actively sends a request to the server to establish a connection. However
In some special cases, the vnc client needs to be monitored. vncsrever initiates a connection request to the client.
Reverse connection.
Main steps:
A. Start the vnc client so that the vncviewer is in the listening state;
# Vncviewer-listen
B. start vncserver
# Vncserver
C. run the vncconnect command on the vncserver to initiate a request from the server to the client;
# Vncconnect-display: 1 192.168.80.135

IX. possible problems:

A. Black Screen
After installing and configuring the VNC server in Linux, a black screen is displayed when multiple users log on to the server. the specific symptoms are as follows:
The client can log on to the system through the IP address and session number, but the login is dark, except for a cross-handed mouse, not necessarily pointed.

Cause: The user's VNC startup file permission is not set correctly.
Solution: change the property of the xstartup (generally:/user directory/. vnc/xstartup) file of the black screen user to 755 (rwxr-xr-x ).
After that, kill all started VNC clients:
Vncserver-kill: 1
Vncserver-kill: 2 (note: There is a space between-kill and: 1 or: 2)
Restart the vncserver service! #/Etc/init. d/vncserver restart

Note: The vncserver can only be disabled by the user who starts it, and the vncserver enabled by other users cannot be disabled by the root user,
Unless the kill command is used to kill the process.

B. how to log on to the VNC Server in mongown?
(1) log on from the browser (the browser must install the JAVA support library and implement it as a java applet to log on to and control the VNC server. you can install yum install java)
Enter the following address in the browser:

Http://xxx.xxx.xxx.xxx: 5801

(2) log on from the VNC client
Install the vnc client on windows and enter xxx. xxx: x to connect to log on.

Note:
A. The input format is IP: Number. the number depends on your own configuration. For example, 192.168.80.128: 1
B. The logon prompt "connection refused (10061)" is displayed because of a linux firewall problem. check the firewall settings.
C. The suffix ": x" should not be less. Otherwise, the error "failed to connect: connection refused (10061)" will be prompted)

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.