Detailed explanation of VNC Server Remote Desktop configuration under CentOS
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 "gnometrictopenvironment" (CentOS 5.x install GNOME Desktop Environment)
# Yum groupinstall "X WindowSystem" "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, password should be set for other accounts.
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)