VNC introduction and how to remotely connect to a remote Linux interface?
Today, we suddenly need to use VNC, but we never used this! Later, I searched for information about this. The following is my rough understanding and use of VNC.
Next we will not introduce the basic components of VNC sources one by one. I believe there is no better introduction than Baidu encyclopedia.
http://baike.baidu.com/link?url=Z6-B80x_mQUjxotyvIFstCc-cce2IJXKSclfwbAPz0JUMuhIBqmfRg4u2ycN7jQ4rbLTcwMwfGF2bJML5cRnfK
Note that:
<Span style = "white-space: pre"> </span> popular Xmanager may also be remotely connected to UNIX or Linux for graphical operations, compared with VNC, VNC works differently. <span style = "white-space: pre"> </span> the former (VNC) is a remote connection to the operating system, all operations are performed on UNIX and Linux host servers. <span style = "white-space: pre"> </span> <span style = "color: # ff0000; "> even if the local computer is disconnected from the operating host during the operation, the operation is not affected. </span> <span style =" white-space: pre "> </span> while the latter (Xmanager) directs the UI of the host server to the local computer through the port for display. <span style =" white-space: pre "> </s Pan> <span style = "color: # ff0000;"> if "the network between the local computer and the operating host is disconnected" during the operation, the Operation will fail! If the tasks in the operation are very important, <span style = "white-space: pre"> </span> cannot be interrupted. For example, if oracle rac is implemented, the result is disastrous! </Span> <span style = "white-space: pre"> </span> More importantly, VNC is free and open-source, xmanager you may use to crack the registration version.
For Linux, you can use:
[root@localhost sysconfig]# cat /etc/issueRed Hat Enterprise Linux Server release 5.5 (Tikanga)Kernel \r on an \m
Check whether vnc is installed:
[root@localhost sysconfig]# rpm -qa| grep vnc-servervnc-server-4.1.2-14.el5_3.1
Download vnc viewer: http://download.csdn.net/detail/u011218159/8340161 in window
There are two ways to configure on the server:
1. Configure through interface operations: System -- preference -- remote desktop -- select all options except (ask you for confiromation options)
2. Use commands to configure:
[root@localhost ~]# vncserver :1You will require a password to access your desktops.Password:Verify:New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1Creating default startup script /root/.vnc/xstartupStarting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost.localdomain:1.log
After the configuration, you can connect to me through the vnc viewer on the client. Here are some problems:
1. The connection is rejected because of the firewall.
One solution: Disable the Firewall
[root@localhost ~]# /etc/init.d/iptables stopFlushing firewall rules: [ OK ]Setting chains to policy ACCEPT: filter [ OK ]Unloading iptables modules: [ OK ][root@localhost ~]# lsanaconda-ks.cfg Desktop install.log install.log.syslog
Configure to the firewall configuration file:
Based on the above introduction, if Linux enables the firewall function, you need to manually enable the corresponding port. For example, to enable the corresponding port with the desktop number "1", the command is as follows: [root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5901-j ACCEPT [root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5801-j ACCEPT
2. The connection interface is different in the above two methods. solution:
Configure the VNC graphic desktop environment as a KDE or GNOME desktop environment. If you configure it according to my above method, it is very simple to log on to the desktop, there is only one Shell available. Why? How can we see the cute and beautiful KDE or GNOME desktop environment? The answer is as ugly as the VNC service uses the twm graphical desktop environment by default. You can modify it in the VNC configuration file xstartup, let's take a look at this configuration file [root @ testdb ~]. # <Span style = "color: # ff0000;"> vi/root/. vnc/xstartup </span> #! /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 /. xresourcesxsetroot-solid greyvncconfig-iconic & xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop" & twm & change the last line of the xstartup file to "startkde &", after restarting the vncserver service, you can log on to the KDE Desktop Environment and mount the last xstartup file. Modify the line to "gnome-session &", restart the vncserver service, and then log on to the GNOME desktop environment to restart the vncserver service: [root @ testdb ~] # Vncserver-kill: 1 [root @ testdb ~] # Vncserver: 1
In this case, there should be no problem, and I have finished writing it !!
The following is my reference. For more information, see the following:
1. Check whether the VNC is installed by default. The Red Hat Enterprise Linux installer installs the VNC service on the system. Check whether the VNC service has been installed and check the installed VNC version [root @ testdb ~] # Rpm-q vnc-servervnc-server-4.1.2-9.el5 [root @ testdb ~] # If the system is not installed, you can find the RPM installation package vnc-server-4.1.2-9.el5.x86_64.rpm for the VNC service under the Server Directory of the operating system installation disk, the installation command is as follows rpm-ivh/mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm2. start the VNC service and run the vncserver command to start the VNC service. The command format is "vncserver: desktop Number". The "desktop number" is represented by a number, the following is an example of a desktop that requires one desktop startup number to be 1 for each user: [root @ testdb ~] # Vncserver: 1You will require a password to access your tops. password: Verify: xauth: creating new authority file/root /. xauthorityNew 'testdb: 1 (root) 'desktop is testdb: 1 Creating default startup script. /root /. vnc/xstartupStarting applications specified in/root /. vnc/xstartupLog file is/root /. vnc/testdb: 1. during the execution of the preceding log command, because it is the first execution, you need to enter a password, which is encrypted and saved in the user's main directory. vnc subdirectory (/root /. in vnc/passwd. vn In the c subdirectory, The xstartup configuration file (/root/. vnc/xstartup) is automatically created for the user. The configuration information in the file is read every time the VND service is started. BTW:/root /. there is also a "testdb: 1. pid file, which records the process number corresponding to the operating system the day after the VNC is started, used to accurately locate the process number when the VNC service is stopped. 3. the relationship between the port number used by the VNC service and the desktop number. The port number used by the VNC service is related to the desktop number. The TCP port number used by the VNC starts from 5900, the corresponding relationship is as follows: desktop number is "1" ---- port number is 5901 desktop number is "2" ---- port number is 5902 desktop number is "3" ---- port number is 5903 ...... The TCP port of Java-based VNC client Web service starts from 5800 and is also related to the desktop number, the corresponding relationship is as follows: desktop number is "1" ---- port number is 5801 desktop number is "2" ---- port number is 5802 desktop number is "3" ---- port number is 5803 ...... Based on the above introduction, if Linux enables the firewall function, you need to manually enable the corresponding port. For example, to enable the corresponding port with the desktop number "1", the command is as follows: [root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5901-j ACCEPT [root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5801-j ACCEPT4. the first way to test the VNC service is to use the VNC Viewer software for login test, the procedure is as follows: Start the VNC Viewer software --> enter "144.194.192.183" on the Server: 1 "--> click" OK "--> enter the login Password with Password --> click" OK "to log on to the X-Window Graphic desktop environment --> the test is successful. The second method is to use the Web browser (such as Firefox, IE, Safari) login test, the operation process is as follows: Enter http: // 144.194.192.183: 5801/--> VNC viewer for Java (this tool is a VNC client program written in Java) in the address bar) in the VNC viewer dialog box, enter "144.194.192.183: 1" and click "OK" --> Enter Password Logon password --> click "OK" to log on to the X-Window Graphic desktop environment --> test successful (Note: VNC viewer for Java requires JRE support. If the page cannot be displayed, indicates that JRE is not installed. You can download the latest jrein installation at http://java.sun.com/javase/downloads/index_jdk5.jsp.) 5. configure the VNC graphic desktop environment as a KDE or GNOME desktop environment. If you configure it according to my above method, it is very simple to log on to the desktop, there is only one Shell available. Why? How can we see the cute and beautiful KDE or GNOME desktop environment? The answer is as ugly as the VNC service uses the twm graphical desktop environment by default. You can modify it in the VNC configuration file xstartup, let's take a look at this configuration file [root @ testdb ~]. # Vi/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 /. xresourcesxsetroot-solid greyvncconfig-iconic & xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop" & twm & change the last line of the xstartup file to "startkde &", after restarting the vncserver service, you can log on to the KDE Desktop Environment and mount the last xstartup file. Modify the line to "gnome-session &", restart the vncserver service, and then log on to the GNOME desktop environment to restart the vncserver service: [root @ testdb ~] # Vncserver-kill: 1 [root @ testdb ~] # Vncserver: 16. To configure multiple desktops, you can use the following method to start VNCvncserver: 1 vncserver: 2 vncserver: 3 ...... However, this manual start method will expire after the server is restarted. Therefore, the following describes how to enable the system to automatically manage VNC on multiple desktops, add the information to be automatically managed to the/etc/sysconfig/vncservers configuration file. Configure desktop 1 as root user desktop 2 as an oracle user as follows: VNCSERVERS = "desktop number: User name used" [root @ testdb ~] # Vi/etc/sysconfig/vncserversVNCSERVERS = "1: root 2: oracle "VNCSERVERARGS [1] ="-geometry 1024x768 "VNCSERVERARGS [2] ="-geometry 1024x768 "7. to change the VNC access password, run the vncpasswd command to modify the VNC password of different users. If the VNC of different users is configured, you must modify the VNC of each user separately, for example, in my experiment, the root user and the oracle user must be modified separately. The modification process is as follows: [root @ testdb ~] # VncpasswdPassword: Verify: [root @ testdb ~] #8. Start and Stop the VNC service 1) Start the VNC service command [root @ testdb ~] #/Etc/init. d/vncserver startStarting VNC server: 1: rootNew 'testdb: 1 (root) 'desktop is testdb: 1 Starting applications specified in/root /. vnc/xstartupLog file is/root /. vnc/testdb: 1. log2: Export lenew 'testdb: 2 (oracle) 'desktop is testdb: 2 Starting applications specified in/home/oracle /. vnc/xstartupLog file is/home/oracle /. vnc/testdb: 2.log [OK] 2) Stop the VNC service command [root @ testdb ~] #/Etc/init. d/vncserver stopShutting down VNC server: 1: root 2: oracle [OK] 3) restart the VNC service command [root @ testdb ~] #/Etc/init. d/vncserver restartShutting down VNC server: 1: root 2: oracle [OK] Starting VNC server: 1: rootNew 'testdb: 1 (root) 'desktop is testdb: 1 Starting applications specified in/root /. vnc/xstartupLog file is/root /. vnc/testdb: 1. log2: Export lenew 'testdb: 2 (oracle) 'desktop is testdb: 2 Starting applications specified in/home/oracle /. vnc/xstartupLog file is/home/oracle /. vnc/testdb: 2.log [OK] 4) settings The VNC service automatically loads as the system starts. The first method is to run the "ntsysv" command to start the graphical service configuration program. Add an asterisk before the vncserver service and click "OK". The configuration is complete. Method 2: Use "chkconfig" to operate in command line mode. Use the following command (for more information about how to use chkconfig, see man) [root @ testdb ~] # Chkconfig vncserver on [root @ testdb ~] # Chkconfig -- list vncservervncserver 0: off 1: off 2: on 3: on 4: on 5: on 6: off