1, first confirm whether the VNC installation
By default, the Red Hat Enterprise Linux Installer installs the VNC service on the system.
Use the RPM command to check if VNC is installed and display the software name if it is installed:
[Email protected]/]# Rpm-qa | grep VNC
Vnc-server-4.1.2-14.el5_6.6.x86_64
If the software name is not displayed if it is not installed, you can find the RPM installation package vnc-server-4.1.2-9.el5.x86_64.rpm of the VNC service under the server directory of the operating system installation disk, or you can go to this website to search for the download http:/ The/rpmfind.net/ installation command is as follows:
[Email protected] home]# RPM-IVH vnc-server-4.1.2-14.el5_6.6.x86_64.rpm
2. Start the VNC service
[Email protected]/]#/etc/init.d/vncserver start #启动VNC服务
Starting VNC SERVER:NO displays configured [OK]
The port number used by the VNC service is related to the desktop number, and VNC uses the TCP port starting with 5900, and the corresponding relationship is as follows:
The desktop number is "1"----port number is 5901
The desktop number is "2"----port number is 5902
The desktop number is "3"----port number is 5903
......
The Java-based VNC client Web service TCP port starts at 5800 and is related to the desktop number, which corresponds to the following
The desktop number is "1"----port number is 5801
The desktop number is "2"----port number is 5802
The desktop number is "3"----port number is 5803
......
During the execution of the following command, because it is the first time, the password needs to be entered and the password is encrypted in the. VNC subdirectory (/ROOT/.VNC/PASSWD) in the user's home directory;
The Xstartup configuration file (/root/.vnc/xstartup) is automatically created for the user in the. VNC subdirectory of the user's home directory, and the configuration information in the file is read each time the VND service is started.
[[email protected]/]# vncserver:1 #启动VNC桌面号 (desktop number equals port)
You'll require a password to access your desktops.
Password:
Verify:
3. Configure the firewall to release the VNC port
[Email protected]/]# Vim/etc/sysconfig/iptables
# Firewall configuration written by System-config-firewall
# Manual Customization of this file are not recommended.
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State--state established,related-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-m State--state new-m tcp-p TCP--dport 22-j ACCEPT
-A input-m State--state new-m tcp-p TCP--dport 5901-j ACCEPT #把桌面号1对应的端口添加到防火墙
-A input-m State--state new-m tcp-p TCP--dport 5801-j ACCEPT #把桌面号1对应的端口添加到防火墙
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT
[Email protected]/]#/etc/init.d/iptables restart #重启防火墙生效
4. Configure VNC Login desktop type (Linux desktop mainly has KDE and gnome two kinds)
The default configuration is very simple to log on to the desktop, because the VNC service uses the TWM graphical desktop environment by default and can be modified in the VNC configuration file Xstartup
, cancel the # # of the following two items in the config file, add a line gnome-session gnome, use the GNOME desktop
[Email protected]/]# echo $DESKTOP _session #查看linux系统使用的桌面类型
Gnome
[[email protected]/]# vim/root/.vnc/xstartup #修改VNC登录桌面配置文件 (the red Word is changed)
#!/bin/sh
# Uncomment the following-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 Gnome
TWM &
[Email protected]/]# Shutdown-r now #重启linux系统让服务生效或禁用vnc服务再重启效果一样
5. Windows System installation VNC client login to Linux desktop
Callout :vncconfig-nowin& on the VNC Remote Desktop Linux Open terminal enter this command to copy the copied text to the Windows desktop, this command expires when VNC is turned off and needs to be re-entered.
Red Hat Linux configuration VNC desktop Remote Tools