Connect to centos remotely with VNC XP

Source: Internet
Author: User
Tags x11vnc tightvnc viewer tightvnc

Reference 1:

Reference Site: http://www.beyourman.com/article.asp? Id = 92

1. Check whether VNC is installed on the local machine (VNC is installed on centos5 by default)

Rpm-q vnc-Server

If the result is:

Package VNC is not installed
Vnc-server-4.1.2-14.e15_3.1

Congratulations! VNC has been installed on the machine. If not, you have to install it on your own. Here we will not talk about how to install it. It is very simple. Search for it in the centos software library and click Install.

2. Add the Remote Desktop user to the configuration file.

VI/etc/sysconfig/vncservers

Use the VI editor to open the configuration file and add the following two lines of commands to the file:

Vncservers = "1: Root" -- specify a remote user

Vncserverargs [1] = "-geometry 1024x768" -- specify the Remote Desktop resolution

3. Set the password for the Remote Desktop user root you just set

Vncpasswd

4. Enable the VNC Port

VI/etc/sysconfig/iptables

Use the VI editor to open the configuration file and add the following command to the file:

-A rh-firewall-L-input-p tcp-m tcp -- dport 5900: 5903-J accept

5. Restart the Firewall

Service iptables restart

6. Modify the remote desktop display configuration file (it is very easy to modify the Remote Desktop without modifying this file, which is equivalent to a command line operation. To perform remote operations, make sure to modify the configuration file by referring to the following methods)

Cd ~ /. VNC/

VI xstartup

Open the configuration file in the VI editor and make the following changes:

# Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop" & -- comment it, and add # To indicate comment

# TWM & -- annotate it

Gnome-session & -- add it

After reading this code, you should understand what is going on.

7. Start the VNC service

/Sbin/service vncserver start

8. remote connection

Open the VNC client and enter IP address 1 in the server box (1 indicates the remote user code configured above. Multiple remote users can be configured in the configuration file ), then you can easily control centos through a friendly Remote Desktop.

Reference Site: http://www.beyourman.com/article.asp? Id = 92

1. Check whether VNC is installed on the local machine (VNC is installed on centos5 by default)

Rpm-q vnc-Server

If the result is:

Package VNC is not installed
Vnc-server-4.1.2-14.e15_3.1

Congratulations! VNC has been installed on the machine. If not, you have to install it on your own. Here we will not talk about how to install it. It is very simple. Search for it in the centos software library and click Install.

2. Add the Remote Desktop user to the configuration file.

VI/etc/sysconfig/vncservers

Use the VI editor to open the configuration file and add the following two lines of commands to the file:

Vncservers = "1: Root" -- specify a remote user

Vncserverargs [1] = "-geometry 1024x768" -- specify the Remote Desktop resolution

3. Set the password for the Remote Desktop user root you just set

Vncpasswd

4. Enable the VNC Port

VI/etc/sysconfig/iptables

Use the VI editor to open the configuration file and add the following command to the file:

-A rh-firewall-L-input-p tcp-m tcp -- dport 5900: 5903-J accept

5. Restart the Firewall

Service iptables restart

6. Modify the remote desktop display configuration file (it is very easy to modify the Remote Desktop without modifying this file, which is equivalent to a command line operation. To perform remote operations, make sure to modify the configuration file by referring to the following methods)

Cd ~ /. VNC/

VI xstartup

Open the configuration file in the VI editor and make the following changes:

# Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop" & -- comment it, and add # To indicate comment

# TWM & -- annotate it

Gnome-session & -- add it

After reading this code, you should understand what is going on.

7. Start the VNC service

/Sbin/service vncserver start

8. remote connection

Open the VNC client and enter IP address 1 in the server box (1 indicates the remote user code configured above. Multiple remote users can be configured in the configuration file ), then you can easily control centos through a friendly Remote Desktop.

9. Automatically Start VNC upon startup

VI/etc/rc. d/rc. Local

Open the configuration file in the VI editor and make the following changes:

/Etc/init. d/vncserver start -- add a row

9. Automatically Start VNC upon startup

VI/etc/rc. d/rc. Local

Open the configuration file in the VI editor and make the following changes:

/Etc/init. d/vncserver start -- add a row

 

Reference 2:

Reference: http://wiki.centos.org/zh/HowTos/VNC-Server

1. install required components

 

The component name of the server is VNC-server. Please executeRpm-q vnc-Server

This command.

Its output should bePackage VNC-server is not installed
Or similarVnc-server-4.0-11.el4
.

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

.

The client program is VNC. IfRpm-Q VNC


Indicates that it is not installed. You can useYum install VNC

Run this command to install it.

Install a window administrator to obtain a normal image desktop. For example, you can useYum groupinstall "GNOME Desktop Environment"

This command is used to install GNOME desktop and required components. Other popular desktop environments include KDE and XFCE-4.4. Xfce is more lightweight than gnome and KDE and has been included in the extras software library.


If you use centos 5,Yum groupinstall "GNOME Desktop Environment"
We may complain that libgaim. so.0 is missing. This is a known error. For more information, see CentOS-5 FAQ
.

 

2. Set unencrypted VNC

 

We will set VNC to three users. They are Larry, Moe, and curly.

You need to perform the following steps to set up your VNC Server:

  1. Create your VNC user.
  2. Set the user's VNC password.
  3. Edit server settings.
  4. Create and customize xstartup scripts.
  5. Guide the VNC service.
  6. Test each VNC user.
  7. Set the VNC service to automatically enable upon startup.
  8. Add selective changes.

 

2.1. Create Your VNC user

 

Use Root
Identity:

 

$ su -
# useradd larry
# useradd moe
# useradd curly
# passwd larry
# passwd moe
# passwd curly

 

 

2.2. Set the user's VNC Password

 

Log on to each account and executeVncpasswd


. In this way,. VNC
Directory.

 

[~]$ cd .vnc
[.vnc]$ ls
passwd

 

 

2.3. Edit server settings

 

Edit/Etc/sysconfig/vncservers
And add the following content at the bottom of the file.

 

VNCSERVERS="1:larry 2:moe 3:curly"
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 640x480"
VNCSERVERARGS[3]="-geometry 800x600"

 

Larry and MoE will have a picture of 640 multiplied by 480. Curly will have a 800x600 image.

 

2.4. Create an xstartup script

 

We will guide and stop the vncserver as the root to create the xstartup script.

 

# /sbin/service vncserver start
# /sbin/service vncserver stop

 

Log on to each account and edit the xstartup script. Take Larry as an example. First, log on toLarry
.

 

[~]$ cd .vnc
[.vnc] ls
mymachine.localnet:1.log passwd xstartup

 

Edit xstartup. The original one should look like:

#!/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 grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

 

This
Add the following line to determine that xterm will often exist. If you want
Normal window administrator of the execution user. Remove the comments of the two rows as instructed. Note that in a VNC, the resolution and color depth may be reduced.
In the window, the entire desktop will be quite narrow and look strange. If you do not remove the comments from those two lines, your VNC window will have a shift background color.

 

#! /Bin/sh
# Add the following line to determine that xterm will often exist.
(While true; do xterm; done )&
# 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 &

 

 

2.5. boot the VNC Server

 

Boot vncserver as root.

 

# service vncserver start

 

 

2.6. test each VNC user

 

 

2.6.1. test with a Java-supported Browser

 

Let's assume that our machine has the IP address 192.168.0.10. The URL to connect to each account will be:

 

Larry is http: // 192.168.0.10: 5801
Moe is http: // 192.168.0.10: 5802
Curly is http: // 192.168.0.10: 5803

 

Connect to http: // 192.168.0.10: 5801
. The window of a Java program will pop up, indicating that you want to connect to Port 1 of the machine. Click [OK. Enter Larry's VNC password, and then a 640x480 window will passLarry
The default window administrator is opened.Iptables
The firewall must open these ports5801, 5802 and 5803
The IP address or sub-network assigned to the client.

 

2.6.2. test with a VNC User Machine

 

 

LARRY: vncviewer 192.168.0.10: 1
MOE: vncviewer 192.168.0.10: 2
CURLY: vncviewer 192.168.0.10: 3

 

To be tested with vncviewerLarry
, ExecuteVncviewer 192.168.0.10: 1
.
Enter Larry's VNC password, and a 640x480 window with Larry's default window administrator will open. Vncviewer
The client will connect to the 590x port, where the X value is equal to 1, 2, and 3 correspond to Larry, Moe, and
Therefore, the firewall must open these ports to the client's IP address or sub-network.

 

2.6.3. Boot vncserver at startup

 

Enter/Sbin/chkconfig vncserver on

This command.

The basic VNC settings are now complete. The following are optional improvements to enhance security and functionality.

 

3. Encrypt VNC through SSH Tunnel

 

You will be connected through an SSH tunnel. You must be able to log on to an account on this machine using SSH. For example, the account on the vncserver is Larry.

  1. Edit/etc/sysconfig/vncservers and add the-localhost option.

    VNCSERVERS="1:larry 2:moe 3:curly"
    VNCSERVERARGS[1]="-geometry 640x480 -localhost"
    VNCSERVERARGS[2]="-geometry 640x480 -localhost"
    VNCSERVERARGS[1]="-geometry 800x600 -localhost"
  2. /Sbin/service vncserver restart

  3. Enter another machine with vncserver and test VNC.
    1. Vncviewer-Larry@192.168.0.10
      Localhost: 1

    2. Vncviewer-Moe@192.168.0.10
      Localhost: 2

    3. Vncviewer-Curly@192.168.0.10
      Localhost: 3

According to pre-settings, many vncviewer will disable the compression option for connections that it considers as "local. See the vncviewer User Manual to enable/impose compression. Otherwise, the performance may be poor!

 

4. Restore after cancellation

 

If you log out of your desktop administrator, it will no longer exist!

  • We have added the line that opens xterm for us in xstartup, so that we can guide our window administrator again.

    • For gnome, enterGnome-session

      .

    • If KDE is used, enterStartkde

      .

 

5. Use VNC-LTSP-config for remote login

 

To allow users to remotely log on to the centos system using the VNC client, you can install components named VNC-LTSP-config and xinetd. When the VNC client is connected to one of the configured ports, you will get a standard logon screen. This work phaseNot
Persistent. When a user logs out, this work phase disappears.

The RPM component VNC-LTSP-config can easily use the existing software library
Page.

Note: The VNC-LTSP-config *. RPM component has no dependencies, so you can simply download and install it without having to enable the epel software library.

Install as root:

 

# yum install xinetd vnc-ltsp-config
# /sbin/chkconfig xinetd on
# /sbin/chkconfig vncts on
# /sbin/service xinetd restart

 

Then, edit the file "/etc/TPD/custom. conf" as the root user.

  • Add disallowtcp = false to the first blank line under the [Security] segment
  • Add enable = true to the first blank line under the [XDMCP] segment
  • Make sure that you have the permission to run the default GNOME installation to execute the gmtr-restart, or simply reboot centos.

This will allow you to connect to the VNC client to obtain the following default work phase:

Resolution

Color Depth

Port

1024x768

16

5900/tcp

800x600

16

5901/tcp

640x480

16

5902/tcp

1024x768

8

5903/tcp

800x600

8

5904/tcp

640x480

8

5905/tcp

 

Enable
Use VNC-LTSP-config
Compared with the standard "one person setting", it can reduce the usage of system resources. Unless a user logs on to the system, the user process will not boot and the memory will not be occupied. In addition, you do not have
Annoying user settings (that is, manually setting VNC-server for individual users is omitted ). What are the disadvantages of VNC-LTSP-config?Any
Users with logon permissions can log on to the image interface through a VNC client, unless you take measures to restrict this type of wiring. In addition, the Work Phase cannot last forever! Once the VNC client is closed, the VNC-LTSP-config phase will be terminated (by default), and all processes in execution will be deleted.

This option can be combined with an improved version of vncviewer-via destiny and SSH tunnel:

vncviewer -via remoteUser@remoteHost localhost:vncSinglePortNumber

 

For the default installation of VNC-LTSP-config, vncsingleportnumber is the last number of port numbers. For example, the port number 5900 (1024x768 16-bit RMB) is only "0 ".

NOTE: If SELinux is enabled
Or iptables
, You need to pay attention to possible interaction problems. If you do not have a running display Management Program (for example, at runlevel 3), you must start one. Otherwise, you will have only one black area when connecting.

 

6. Provide VNC servers for the login image working phase-two options

 

Very
For a long time, you need to remotely access an image working phase that is logged on through the "real" console. Alternatively, you may need to remotely assist a user in solving image interface or visual problems. You will need
VNC-server or x11vnc. VNC-server this option uses a module to add the standing VNC support to X11, while x11vnc
Temporary VNC support is allowed.

Installing VNC-server does not require third-party software libraries or source code creation.

X11vnc provides a methodAllows you to remotely view and interact with X images (including displays, keyboards, and mouse) from the VNC Viewer. In this way, it plays the role of WinVNC on Windows on UNIX/X11.

 

6.1. Temporary Use of x11vnc

 

Karl Runge generously in http://www.karlrunge.com/x11vnc/
Provides a large amount of information for x11vnc. This section describes how to improve connection security and how to use enhanced TightVNC viewer "enhanced TightVNC viewer" (ssvnc ). To put it simply, follow these steps:

  1. From http://dag.wieers.com/rpm/packages/x11vnc/
    Download the latest RPM to the host you want to connect to with the VNC client:

    wget http://dag.wieers.com/rpm/packages/x11vnc/x11vnc-0.9.3-1.el5.rf.i386.rpm
  2. Use Yum or rpm for installation on the host to be connected as root:

    yum install x11vnc-0.9.3-1.el5.rf.i386.rpm
  3. Guide the x11vnc process on the host to be connected. Check all the options listed on the x11vnc page. An example of a simple/insecure network that can be used by a trusted network (local network or VPN) is to be executed by a user with an image console:

    [user@helpme_host ~$] x11vnc -nopw -display :0.0

Then, connect to the IP address/host name indicated by the x11vnc command through the VNC client (without a password. By default, x11vnc accepts connections from all interfaces. The firewall settings on the host may need to be modified.

You can use it together with the SSH tunnel:

Ssh-c-t-l 5900: localhost: 5900 [remote IP] 'x11vnc-usepw-localhost-display: 0'

 

Note-C
Select the compression option, so it is not required

 

6.2. permanent use of VNC-server on X11

 

  1. On the system where you want to run VNC-server, install VNC-server as shown above.
  2. Edit/etc/X11/Xorg. conf as root, add/create a module segment and addLoad "VNC"
    :

    Section "Module"
    Load "vnc"
    EndSection
  3. Use standard VNC authentication, edit/etc/X11/Xorg. conf as root, and add the following content to the screen segment:

      Option "SecurityTypes" "VncAuth"
    Option "UserPasswdVerifier" "VncAuth"
    Option "PasswordFile" "/root/.vnc/passwd"
  4. Run vncpasswd as root and create a password as shown above.
  5. Reboot X11 (if you are already on the console, use <Ctrl> + <alt> + <BS>)

  6. You should be able to normally use the vncviewer client for connection.
  7. To troubleshoot the problem, check the error in/var/log/xorg.0.log and make sure that iptables or SELinux does not interfere with the remote connection. Additional information has been included in the http://www.realvnc.com/products/free/4.1/x0.html
    .

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.