Detailed tutorial on setting up VNC remote control software in Linux

Source: Internet
Author: User
Tags pcanywhere

VNC introduction:

Although VNC still lacks the ability to call Chinese Input by Hot Key in Linux, it still cannot block its position in Linux. Let's take a look at its charm. First of all, it's very casual to copy and paste it. Copy the local machine and paste it directly in the remote machine. Very convenient.

Network remote control technology refers to a computer (master) to control another computer (controlled), and when the master is on the control end, just as users sit in front of the controlled terminal, they can execute the controlled application and use the system resources of the controlled terminal.

VNC (Virtual Network Computing) is a set of software developed by the at&t lab that can control remote computers. It adopts the GPL authorization terms and anyone can obtain the software for free. The VNC software consists of VNC Server and VNC Viewer. You must first install the VNC server on the controlled computer before you can control the controlled terminal on the control terminal.

(In windows, a set of well-known remote control software called pcAnywhere, is also released by Symantec.

VNC Server and VNC Viewer support multiple operating systems, such as UNIX, Linux, Solaris, windows, and MACOs, therefore, you can install the VNC Server and VNC Viewer in different operating systems for control. If the current master computer does not have VNC Viewer installed, you can control the control end through a general web browser.

The workflow for running the entire VNC is as follows:

(1) connect the VNC client to the VNC server through a browser or VNC Viewer.

(2) The VNC server sends a dialog window to the client, requiring that you enter the connection password and access the VNC Server display device.

(3) After the client enters the online password, the VNC Server verifies that the client has access permissions.

(4) If the client passes the VNC Server verification, the client requires the VNC server to display the desktop environment.

(5) The VNC server uses X protocol to require X server to assign control of the display to the VNC server.

(6) The VNC server will be sent to the client using the VNC communication protocol in the desktop environment of X server in the future, and allow the client to control the desktop environment and input device of the VNC server.

Installation and Use of VNC

My operating environment: redhat9.0 on the control side and Windows XP on the control side.

1. Download VNC Server and VNC Viewer.

VNC Server: http://www.Linuxeden.com/download/softdetail.php? Softid = 744

VNC Viewer: http://download.pchome.net/php/dl.php? SID = 1, 2603

2. install.

Rpm-uvh VNC-3.3.6-2.i386.rpm (for source code, see the instructions in the package)

After downloading the Linux version of VNC, you can extract the file to a folder, such as/home/VNC, and then copy the file vncserver, vncpasswd, and xvnc to the/usr/bin directory. If you want to remotely control a Linux computer through the Integrated Java interface of the VNC server, you also need to create a sub-directory/usr/local/VNC/classes. After this subdirectory is created, copy the vncjava. Class file to this directory. (Generally, RedHat 9.0 comes with the above files, so you can directly use the terminal to execute it ).

Under Yum on fedora 8, click the giant. I have never looked at how to install it.

3. Start VNC Server on Linux

Run the vncserver command:

[Root @ linux root] # vncserver

You will require a password to access your tops.

Password: ---- to prevent anyone from remotely controlling the computer. Therefore, when you start the VNC Server for 1st times, you must set a remote control password. This is your login VNC password must be safe enough. It seems that users can be configured in any article. However, 80% of users are not used to distinguishing users. Because VNC can Virtualize n desktops. Hooko, with Linux users, is very good and powerful.

Creating default startup script/root/. VNC/xstartup

Starting applications specified in/root/. VNC/xstartup

Log File is/root/. VNC/Linux: 1.log

(After the preceding steps, the VNC Server is started. If you want to change the VNC server password, you only need to execute the vncpasswd command .)

 

4. Run VNC Viewer on Microsoft Windows

Run unzip vncviewer.exe directly. The connection details dialog box is displayed.

In the connection details dialog box, enter the IP address of the VNC Server (or host name and display device number) in the "VNC Server" text box (see 3. Start this line of the VNC Server on Linux. New 'X' desktop is Linux: 1 to get this information. For example: 192.168.0.1: 1 (1 after the colon is the display device number generated by the VNC Server). After you click the "OK" button, the VNC server starts to check the entered information. If the information is incorrect, the system displays the "failed to connect to server" error message: if the information is correct, the "VNC authentication" dialog box appears.

If the password entered in the "VNC authentication" dialog box is correct, you can successfully open the Linux desktop window.

5. remote control from the browser.

Start the VNC Server and open your browser. in the address bar, enter the address or IP address of the controlled terminal, and add the port number ": 5800 + display number" to the address to control the computer.

For example: http: // 192.168.0.1: 5801 (if the display number is 1, the display number set for the first time is 1, 5800 + 1 = 5801 .)

If you see the window, it indicates that you have succeeded. You can remotely control it by entering the password in the password box.

It's okay. Who should use a browser ..... Boring step

6. Set the vncserver startup variable:

To ensure that the vncserver port number remains unchanged at each startup (5901)

Add the following command to the/etc/rc. d/rc. Local file:

Rm-F/tmp/. X11-unix/x *

Rm-F/. VNC/*. PID

Rm-F/. VNC/*. Log

In this way, the system will first Delete the temporary files left when the last abnormal shutdown is started.

8. End the VNC service and Remote Desktop

Vncserver-kill: 1

For more detailed usage, use man.

The Windows Manager set in VNC is TWM, which may be different from the one you use. You can change the configuration file of VNC to your favorite one by modifying the configuration file. The method is as follows:

Modify the. VNC/xstartup file in the user directory

#! /Bin/sh

[-R $ home/. Xresources] & xrdb $ home/. Xresources

Xsetroot-solid gray

Vncconfig-iconic &

Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "&

TWM &

#! Comment out all the content after/bin/sh and change it

~ /. Xclients

Save files

Now you can test whether the modification is successful. Kill the vncserver service first.

Vncserver-kill:

Or

Pa aux | grep xvnc

Kill PID

Restart vncserver and use vncviewer to connect to the Remote Desktop.

In the previous article on VNC server settings, we can run vncserver on a Linux server for remote access, but note that:

If you directly use vncviewer for access, there are two disadvantages:

1. Password transmission is in plain text and can be easily listened.

2. the firewall needs to open port 59xx, which is impossible in the normal unit.

Fortunately, we have SSH, a powerful tool, like X11 forwarding. We can use the SSH tunnel to protect the communication process. The following is a brief introduction.

Assume that the vncserver runs on screen 1 of myserver (IP Address: 192.168.x.x), that is, It listens for 192.168.x.x: 5901, and the user name is foo.

Scenario 1: The VNC client is Linux

This situation is very simple. Ssh suites are installed by default in general Linux releases.

1. log on to the server using SSH

Ssh-l 5901: localhost: 5901-l Foo myserver

Or directly use an IP address.

Ssh-l 5901: localhost: 5901-l Foo 192.168.x.x

2. Run vncviewer (or other similar tools) on another terminal on the local machine)

Vncviewer localhost: 1

Scenario 2: The VNC client is Windows

1. Download an SSH client, personal recommendations putty, only one program, do not need to install, simple and functional. Download http://www.chiark.greenend.org.uk here /~ Sgtatham/Putty/download.html

Download putty.exe and run it directly on the desktop.

2. Run putty, enter the IP address of the server, and enter a name. Here, myserver serves as the session name, and press save to save. See figure 1.

3. Click tunnels on the left of the dialog box to select related settings, enter 5901 in source port, enter localhost: 5901 in destination, and press add, as shown in figure 2.

4. Click Session on the left side, return to session settings, and press save to save the settings. Click Open to log on to the server.

5. run VNC-Viewer (if not, download http://www.realvnc.com/download.html, just use an EXE file) and enter localhost: 1 in the server. See figure 3, after the password is entered, a Linux desktop will appear in windows, and it is very safe. Cool can play this step, all of which I worship. Ha

 

 

51cto Editor's note: Highlights of VNC FAQs

Q. What is VNC?

VNC has two definitions: software and protocol.

VNC is virtual network computing

Software is a shared software under the GNU Public License that complies with the VNC protocol ,. at the beginning, it was developed by at&t's UK lab [now the Group has established RealVNC. this mainly enables the computer to remotely control another computer. Many companies have developed various VNC Based on VNC, which can run on various operating systems.

VNC protocol. Communication protocol between the Controller and the controlled computer. The protocol used by VNC is RFB. [many people do not know it] RFB Protocol is here. Http://realVNC.com/docs/rfbproto.pdf

Q. What are the advantages of VNC?

First, the biggest advantage of VNC is cross-platform. Because the interface processing methods of different operating systems are different, some people have developed different VNC versions, because they all comply with the VNC protocol, so the compatibility is better. Someone else has made a Java client that can run the client on machines that can run JVM.

[Of course, Microsoft, uanywhere, and Linux have their own solutions, such as terminal, pcAnywhere, and xceed. But they do not open code...]

Second, there are many versions, open source code, and everyone can continuously improve it.

[This is an open benefit]

Third, speed. The speed is quite fast, if your network bandwidth is good.

Q. vnc pk ms Terminal

VNC: Windows account/password is not required. This is convenient for one-time users. Otherwise, it is not safe to add users to Windows every time.

Windows: Windows Server can be accessed by multiple users. VNC can only be used by two people (controlled and controlled computers.

VNC: allows control and controlled screens to be displayed and operated simultaneously. In this way, you can perform demo and shared communication. Windows does not have this function!

Q. How can I log on to the controlled terminal through a graphical interface?

Edit ~ /. 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 gray

Vncconfig-iconic &

# Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "&

Gnome-session & it is recommended to select this... Add # To the front of all others #

Startkde &

TWM &

Gnome-session is used to start the gnome GUI; startkde is used to start the kde gui; TWM is used to start the text interface. Choose one of the three.

Q. How can I enable the VNC service automatically upon startup?

Choose system Settings> Server Settings> services, select vncserver, and click Save ".

Modify/etc/sysconfig/vncservers

Vncservers = "1: Root 2: phred 3: SysAdmin" 1 stands for "desktop 1" and root stands for the user name; multiple user desktops can be started simultaneously

Vncserverargs [1] = "-geometry 800x600-alwaysshared-depth 24"

-Alwaysshared indicates that multiple users are allowed to log on at the same time. The value of depth is 8, 16, 24, and 32.

This step is a bit advanced... It is also complicated. In fact, the client can complete the configuration of 80%. I have a better method, because SSH is enabled by default. Open VNC over ssh. There is only one command. Security is more important.

Q. Why is there only one terminal window on the desktop after the connection?

Try to modify/root/. VNC/xstartup and change the last line of TWM & to gnome-session & or KDE & (it is said that KDE is not stable in the current VNC Viewer)

Q. Why can't I connect after I restart the VNC server?

When you restart the VNC server, the system will specify a new display number. You must use this new number. Otherwise, the connection will fail.

View the VNC desktop number and monitoring process

[Root @ Linux/] # netstat-tlnp | grep VNC

The vncserver command has some useful parameters, which can be viewed using vncserver -- help.

A brief explanation:

Vncserver [:] [-name] [-geometry X] [-depth]

[-Pixelformat format]

Vncserver-kill: Display

:

The display Number of the VNC service. You can specify it by yourself. Do not use the default value of the system to ensure security. It must be a non-zero positive integer.

Vncserver: 99

During use, you must enter the correct display number to connect. In the browser, add the display number to the port number. The default port is 5800. For remote connection, enter XXX. XXX: 5899.

-Name: Specifies the vncserver desktop name.

For example, to display the name as "Red Hat"

Vncserver-name Red Hat

-Geometry X indicates the desktop resolution. The default value is 1024x768.

Vncserver-geometry 800x600

This command is useful in practice. For example, if the local resolution is 1024x768, if the remote VNC resolution is not set, the desktop display will be incomplete.

-Depth: Specifies the display color. The value ranges from 8 to 8 ~ 32

Vncserver-depth 16

Display in 16 bits color

-Pixelformat: the specified pigment format is roughly the same as-depth, but the representation method is different.

Vncserver-pixelformat rgb888

Display in 24 bits color

Vncserver-kill: Display

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.