Black screen connection in VNC

Source: Internet
Author: User

Today, I tried to install a VNC Server on centos. Centos5 already comes with VNC, which is also installed by default. You only need to configure it. (if not, you can install Yum install VNC vncserver ). For Windows clients, you only need to install a vncviewer, such as RealVNC.

After the configuration is installed, it cannot be used. There are two problems:

1. Unable to connect to the VNC server.
2. A black screen will appear after the connection.

 

The solution is summarized as follows:

Vncserver Configuration:

1. modify the configuration file/root/. VNC/xstartup

Note: Some system configurations include-nolisten TCP and-nohttpd, which prevent xwindows login and http vnc login. If you need a graphical interface, delete this part.


If you are using the gnome image interface, you need to comment out the following two lines,
# Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "&
# TWM &
And add the following line:
Gnome-session &

For example, my configuration file is as follows:
#! /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 "&
# TWM &
Gnome-session &

2. Modify the user configuration file:/etc/sysconfig/vncservers


Open the configuration file VI/etc/sysconfig/vncservers and remove the "#" before the following two rows. That is to say, remove the comments of the two rows.
Vncservers = "1: Root"
Vncserverargs [1] = "-geometry 800 × 600"

1 indicates that VNC runs on desktop 1, so that the root desktop can be started. You can add other users, such as vncservers ="

1: Root, 2: user1, 3: user2 ", of course, these users implement system existence.

For example, my/etc/sysconfig/vncservers configuration file is as follows:

Vncservers = "1: Root"
Vncserverargs [1] = "-geometry 800 × 600"

In addition, if you have an image interface, you can check the vncserver in system Settings> Server Settings> service and start it with the system.

 

3. Change the xstartup permission.

This problem is easily overlooked by many people and is also one of the reasons for the success of the connection.

In centos, The xstartup file path is/root/. VNC/(you can use locate xstartup to view the xstartup file path)

Therefore, run: chmod 777 root/. VNC/xstartup.

4. Disable firewall restrictions on VNC ports
If you want to control a Linux instance on the Intranet from the Internet, you need to open the corresponding port of the firewall and perform port ing on the vro.
The port number that VNC gives to the browser is 5800 + N, the port number for vncviewer is 5900 + N, and N is the set display number.

If you do not want to enable the firewall but still need the VNC service, you need:

Edit VI/etc/sysconfig/iptables
Add the following two lines to it:
-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

What is needed here is that the port corresponding to the display n is 5900 + N, so it is not recommended to set too much.

5. Start VNC Server:
Open the terminal and run: vncserver
When you run vncserver for the first time, you are required to enter the password twice. The following message is displayed:
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
": 1" in the preceding information indicates the first VNC desktop to be started.

6. Stop vncserver: (optional)
To stop a vncserver, run: vncserver-kill: 1.
Note: ": 1" indicates that the first VNC desktop is stopped, 1 indicates the number of the currently enabled vncserver, and there is a space before ": 1. If the number currently started is 2, to disable it, use "vncserver-kill: 2 ".

7. Change VNC password: (read only)
To change the VNC password, run: vncpasswd.

Enter the password twice.

8: Check whether the VNC server on the server is running normally.:

Run: PS-Ef | grep VNC

If the VNC is running, you can see similar messages:

[[Email protected] ~] # Ps-Ef | grep VNC
Root 3605 1 0 jul13? 00:13:51 xvnc: 1-desktop myims. Local: 1(Root)-httpd/usr/share/VNC/classes-auth/root /. xauthority-geometry 800x600-depth 16-rfbwait 30000-rfbauth/root /. VNC/passwd-rfbport 5901-PN

The VNC process listens on port 5901.

9. VNC client

After the server runs normally, we can consider using the VNC client to connect to it.
Configuration of Windows client VNC Viewer:
1. Download VNC Free Edition for Windows version 4.1.2 from the http://www.realvnc.com/download.html
2. Open vncviewer:
Enter the IP address of the vncserver: Number (1 or 2 or ...)
3. vncviewer switch to full screen mode: F8

10 configuration files:
/Etc/X11/Xorg. conf set screen resolution

At this point, your VNC should be connected, but there may be a black screen problem:

1. Check the log under/root/. VNC/. Is there any error? It may be that the xstartup permission is insufficient. Change "chmod xstartup 777"

Permission. Restart the instance and try again.

2. Restart your computer and try again. I am a black screen after various configurations, and OK after restarting the computer.

Black screen connection in 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.