Configure Remote Desktop in CentOS

Source: Internet
Author: User

Configure Remote Desktop in CentOS

Environment:

CentOS 6.3 Final. All components except KDE are installed on the desktop.

1. Install the service

[Plain] view plaincopy
  1. Yuminstalltigervnc-server

The name is a bit strange. CentOS5 is called vnc-server.

2. Run and set the password

[Plain] view plaincopy
  1. Vncserver [: 1]

Enter the password to generate related files.

[Plain] view plaincopy
  1. Xauth: creatingnewauthorityfile/root/. Xauthority
  2. New 'centos6-244: 1 (root) 'comment topiscentos6-244: 1
  3. Startingapplicationsspecifiedin/root/. vnc/xstartup
  4. Logfileis/root/. vnc/centos6-244: 1.log

3. Configure the user

[Plain] view plaincopy
  1. Vim/etc/sysconfig/vncservers
Add the last line:

VNCSERVERS = "1: root" multiple users are separated by spaces. First, su-to the user to run vncserver [: n] to set the configuration file and password.

4. Practical commands

Usage: vncserver [: <number>] [-name <desktop-name>] [-depth <depth>]
[-Geometry <width> x [-Pixelformat rgbNNN | bgrNNN]
[-Fp <font-path>]
[-Fg]
<Xvnc-options>...


Vncserver-kill <X-display>
Vncserver-list

Vncserver [: n] Service Activation

Several vncserver-list statements are running.

Vncserver-kill: n kills the nth x-display

Vncpasswd Change Password

5. Service Management

Service vncserver restart

Other usage:/etc/init. d/vncserver {start | stop | restart | try-restart | status | force-reload}

Chkconfig vncserver on is added to self-start (chkconfig -- level 35 vncserver on)

6. Client Connection

CentOS: Use TigerVNC Viewer to connect to ip Address: 1

Windows: Use RealVNC Viewer to connect to ip Address: 1

Enter the password to access


========================================================== ========================================================== ====================

You must understand:
When the vncserver is called, it will enable the server listening port according to your configuration,
By default, the port starts from 5900 and your desktop number is added.
For example, if your desktop number is 1, the connection Port Number of vnc is 5900 + 1 = 5901.
For example, if your desktop number is 10000, the connection Port Number of vnc is 5900 + 10000 = 15900.
========================================================== ====================================
Configure the VNC Server below so that the user (root) can remotely connect to the linux system GUI through the vnc client (provided that the desktop is installed on your server)

1. Check whether VNC is installed in linux.
Enter the following command in the terminal window:

Rpm-q vnc-server

The returned information is as follows:

Package vnc-server is not installed

The vnc server is not installed.
2. Run the following command for installation:

Yum install vncvnc-server

3. Start the VNC service

Vncserver
You will require a password to access your tops.
Password:
Verify:

You will be prompted to enter the password, which is required for remote logon. Enter the password and press Enter.
4. Switch to the root account: su root and enter the password of the root account.

Vi/etc/sysconfig/vncservers # vnc configuration file
VNCSERVERS = "10000: root" # cancel the previous #10000: root (desktop number: User)
# VNCSERVERARGS [2] = "-geometry 800x600-nolisten tcp-localhost"

Save and exit
5. configure the firewall to allow port 10000 + 5900 = port 15900 to pass through the firewall (otherwise, the VNC Server cannot be remotely connected)

Vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 15900-j ACCEPT (allow port 15900 to pass the firewall)

Save and exit
6. Restart the vnc server.

/Etc/init. d/vncserver restart
Or
Service vncserver restart

7. Restart the firewall to make the port configuration take effect.

/Etc/init. d/iptables restart
Service iptables restart

8. Set the vnc server to automatically start upon startup
Method 1: run the "ntsysv" command to start the graphical service configuration program. Add an asterisk to The vncserver service and click "OK". The configuration is complete.
Method 2: Use "chkconfig" to operate in command line mode. Use the following command:

Chkconfig vncserver on
Chkconfig -- list vncserver
Vncserver 0: off 1: off 2: on 3: on 4: on 5: on 6: off

9. Change the vnc connection password
Vncpasswd
At this point, the VNC server has been set up and can be connected using the VNC client.
Vnc Server: Your ip: 15900

Note: If the gray screen appears after the connection, you can set it as follows:
Enter the user's home directory, cd/home/user
If you log on with the root account, the current directory is the root directory of the user.

Cd ~ /. Vnc
Vi xstartup # Edit
# Twm & # comment out this line
Gnome-session & # Add this line

Save and exit to connect normally!

This is a success. Next you can use http: // IP: port to log on to the WEB, for example

Http: // IP: 5801. You can also use IP: 1 in vncviewer to log on.

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.