Remote Desktop Connection to Linux-VNC in Windows

Source: Internet
Author: User
Tags ssh port

Author: hiloves)

Blog: http://www.cnblogs.com/hiloves/

Reprinted please keep this information

 

VNC was developed by the at&t laboratory and is an excellent remote control tool software. Later, it was open-source in the form of GPL authorization. After several years of development, the current VNC does not refer to a software, but the general name of a software. The following describes two commonly used VNC software in Linux.

The principle of VNC is to constantly take screenshots of the window interface and transmit the images to the client. At the same time, The VNC Server takes over the keyboard and mouse control of the server, and the client can manipulate the keyboard and mouse on the server. It is similar to pcAnywhere in windows.

 

I. Windows Settings

The reason is that the following two VNC instances can be connected to the same client.

On Windows, I chose RealVNC as the client. It's a green software. You can copy it from the installation directory to another computer and run it.

 

Ii. vino

Vino is a VNC software integrated in GNOME. It is installed by default when the gnome environment is installed. Click "System"-"Preferences"-"Remote Desktop" to open the Configuration window.

After "allow others to view your desktop" is selected, vino starts the server process vino-server and listens to TCP port 5900. If "allow other users to control your desktop" is not selected, the client can only watch and cannot manipulate it.

The vino mode is very different from the xvnc described below. I think vino is actually "Remote Assistance in Windows ", because the desktop displayed on the client is the same as the desktop displayed on the Linux local display, If you manipulate the mouse on the client, the Linux display can also see that the mouse is running. If you have installed a VNC Server in windows, this is the result.

In addition, the bandwidth usage of vino is abnormal. Even if no operation is enabled on the desktop, the bandwidth will be 4-5 Mbps (desktop 1280 × 1024, color 24 ), if any operation is performed, it will take 8-12 Mbps.

Therefore, vino is not suitable for daily remote management of servers. It is suitable for Remote Assistance and remote teaching in Linux. That is to say, if you encounter a problem, experts can teach you how to watch the screen directly, or reproduce faults. You can reproduce faults or bugs locally, while engineers can watch them remotely.

 

Iii. xvnc

Xvnc is a familiar VNC or vncserver. It is an open-source version of VNC software developed by RealVNC.

 

1. Install xvnc.

When installing Linux, you can select from the installation package. If no installation is available, you can find it in the installation disk.

The component name of the server is VNC-server. Run the rpm-q vnc-server command.

Its output should be package VNC-server is not installed or similar to a vnc-server-4.0-11.el4.

If the server is not installed, use this command to install it: Yum install VNC-server.

 

2. Start vncserver.

Enter:

Vncserver: 1-geometry 1280x1024-depth 24 Note: 1 refers to window 1,-geometry refers to window resolution, and-depth refers to the number of colors

You can also specify the following parameters:

Vncserver: 1 Note: With the RealVNC Client, you can specify the window resolution and color number on the client.

When you start vncserver for the first time, you need to specify a password, which is required when you connect to the VNC client.

The window can be specified from 0. If the Linux local side has enabled the graphical environment, it must be specified from 1 because window 0 is occupied by X11.

 

3. Configure xstartup

Xvnc uses TWM as the graphical environment by default. If KDE or gnome is installed, it can also be started.

VI ~ /. VNC/xstartup

The following content is displayed:

#! /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 &

 

The last line of TWM & indicates to start TWM, change it to gnome-session & start gnome, and change it to startkde & start KDE.

If the gnome or KDE graphical environment is enabled on the Linux local end, after the VNC client connects to the server, only the gray screen may be displayed and the graphic environment is not enabled properly. View ~ /. The error message "you are already running a session manager" is displayed in the logs of VNC.

Remove

# Unset session_manager

# Exec/etc/X11/xinit/xinitrc

Before the two rows, restart the vncserver. If the local Linux is in init 3 mode, you do not need to modify these two lines.

When the VNC client connects to the server, the interface is displayed in English, mainly because the Chinese environment has not been loaded and there is no Chinese input method. Add the following content after the # exec/etc/X11/xinit/xinitrc line:

Export lang = zh_CN.UTF-8 Note: Enable Chinese Environment

Scim-D Note: load the scim Input Method

 

4. Disable vncserver

Vncserver-kill: 1 Note: Close Window 1, and close window 2 as follows: 2

The vncserver service is closed when all windows are closed.

 

5. Client usage

Xvnc not only supports client programs such as vncview, but also supports browser control.

Enter http: // ip: 5800 in the browser to start the Java client connection.

Window 0 occupies TCP port 5900 (VNC client) and TCP port 5800 (browser ).

Window 1 occupies TCP port 5901 (VNC client) and TCP port 5801 (browser ).

Windows 2 and 3, and so on.

 

6. Start vncserver at startup

In the preceding operations, you must first log on to the Linux end and then manually start the vncserver service before using the VNC connection. This is required if you want to start the vncserver service on your own.

Start the vncserver once in the preceding steps to ensure that both the password and the xstartup file are created.

Then, add the following content to VI/etc/sysconfig/vncservers:

Vncservers = "1: Root 2: Zhang 3: Li" Note: 1, 2, and 3 represent windows. For example, the root user uses window 1, and the Zhang user uses window 2, users here refer to the regular user accounts in Linux

Vncserverargs [1] = "-geometry 640x480-depth 24" NOTE: Specify the resolution and color number for the root user. [1] indicates "1: Root"

Vncserverargs [2] = "-geometry 640x480-depth 16" NOTE: Specify the resolution and color number for the user of Zhang.

Vncserverargs [3] = "-geometry 800x600"

Note: The preceding three lines can be left blank. The VNC client automatically controls the resolution and color. The above root, Zhang, and Li users must ensure that both the password and the xstartup file are created. you can log on to and execute vncserver: 1 first.

Finally, run the/sbin/chkconfig vncserver on command.

 

7. Security

Xvnc data transmission is in plain text. Because server management is involved, plaintext is unacceptable.

We can use SSH to encrypt VNC data.

First, enable the SSH service on Linux.

Second, download an SSH Telnet tool on Windows. Putty and securecrt are recommended.

Third, enable the SSH tunnel. The following uses securecrt as an example. Putty operations are similar.

Create a common SSH session to connect to Linux.

In this session option, add "local port forwarding attribute" to "port forwarding ".

As shown in the picture on the right, enter a port in "local". Here 5901 is selected, or 5801 or another port can be selected, as long as it does not conflict with the local service, this local port has nothing to do with the window port listened by the vncserver in Linux. In "remote", enter 5901. This port is the port listened by the vncserver in Linux. Here is the start window 1, if the start window is 2, enter 5902 here. OK.

After setting, start the SSH session with Linux in securecrt and log on to Linux correctly. Open vncviewer.

On the VNC Server, enter: localhost: 5901 (the port here is the local port specified above, rather than the Linux port ), this is because the SSH tunnel started by the local securecrt is connected. Securecrt cannot be disabled during VNC running.

In this way, the firewall on the Linux end can only open the ssh port and close all the ports related to VNC.

 

8. Conclusion

Xvnc is a good server management tool for daily use. You can adjust the image quality based on your network bandwidth. If your bandwidth is small, you can adjust the resolution and color quantity, when xvnc is not operated, there is basically no data. If the resolution is 800 × 600, and the image quality is the worst, it will only occupy several hundred kb or even dozens of KB of bandwidth, this is very suitable for server management.

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.