How to install and configure a VNC server on CentOS 7.0

Source: Internet
Author: User
Tags centos server remote desktop access windows remote desktop tightvnc viewer

This is a tutorial on how to install the VNC service on your CentOS 7 installation. Of course this tutorial is also suitable for RHEL 7. In this tutorial, we will learn what VNC is and how to install a VNC server on CentOS 7.

As we all know, as a system administrator, most of the time is through the network Management Server. In the process of managing the server, the graphical interface is seldom used, and in most cases we just use SSH to complete our management tasks. In this article, we will configure VNC to provide a way to connect our CentOS 7 server. VNC allows us to open a remote graphics session to connect to our server so that we can remotely access the server's graphical interface over the network.

The VNC server is a free open source software that allows users to access the server's desktop environment remotely. The VNC Viewer is also required to connect to the VNC server.

Advantages of some VNC servers:

    • Remote graphical management makes work easy and easy.
    • The Clipboard can be shared between the CentOS server host and the VNC client machine.
    • Graphical tools can also be installed on the CentOS server to make the management capability more powerful.
    • The CentOS server can be managed by any operating system as long as the VNC client is installed.
    • More reliable than SSH graphics forwarding and RDP connections.

So, let's start the journey of installing a VNC server. We need to follow the steps below to build a VNC that is available in one step.

First, we need an available desktop environment (X-window), and if not, install one first.

Note: The following commands must be run with root privileges. To switch to root, run "sudo-s" under terminal, not including double quotes ("")

1. Installing X-window

First we need to install X-window, run the following command in the terminal, the installation will take a little time.

    1. # yum check-update
    2. # yum groupinstall "X Window System"

    1. #yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts

    1. ### 设置默认启动图形界面
    2. # unlink /etc/systemd/system/default.target
    3. # ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

    1. # reboot

After the server restarts, we have a working CentOS 7 desktop environment.

Now, we're going to install the VNC server on the server.

2. Installing the VNC server

Now it's time to install the VNC server on our CentOS 7. We need to execute the following command.

    1. # yum install tigervnc-server -y

3. Configuring VNC

Then, we need to /etc/systemd/system/ create a configuration file in the directory. We can /lib/systemd/sytem/[email protected] copy a sample of the configuration file.

    1. # cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service

We then opened it with our favorite editor (the nano we used here) /etc/systemd/system/[email protected]:1.service and found the following lines, replacing them with their own usernames. For example, my username is linoxide so I replace it with Linoxide:

    1. ExecStart=/sbin/runuser -l <USER>-c "/usr/bin/vncserver %i"
    2. PIDFile=/home/<USER>/.vnc/%H%i.pid

Replaced by

    1. ExecStart=/sbin/runuser -l linoxide -c "/usr/bin/vncserver %i"
    2. PIDFile=/home/linoxide/.vnc/%H%i.pid

If it is the root user

    1. ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
    2. PIDFile=/root/.vnc/%H%i.pid

OK, here's the restart SYSTEMD.

    1. # systemctl daemon-reload

Finally, the user's VNC password will be set. To set a user's password, you must have the ability to switch through sudo to the user's permission, here I use linoxide permissions, execute " su linoxide " on it.

    1. # su linoxide
    2. $ sudo vncpasswd

Make sure you enter more than 6 characters in the password

4. Turn on the service

Use the following command (permanently) to open the service:

    1. $ sudo systemctl enable [email protected]:1.service

Start the service.

    1. $ sudo systemctl start [email protected]:1.service
5. Firewall settings

We need to configure the firewall for the VNC service to work properly.

    1. $ sudo firewall-cmd --permanent --add-service vnc-server
    2. $ sudo systemctl restart firewalld.service

Now you can use the IP and port number (LCTT: For example, 192.168.1.1:1, where the port is not the server's port, but depending on the number of VNC connections starting from 1) to connect to the VNC server.

6. Connect to the server with a VNC client

OK, now that the VNC server has been installed. To use VNC to connect to a server, we also need a VNC client installed on the local computer that is only available to connect to the remote computer.

You can use a client like Tightvnc Viewer and Realvnc Viewer to connect to the server.

To connect with more users, you need to create a configuration file and port, go back to step 3rd and add a new user and port. You need to create [email protected]:2.service and replace the user name in the configuration file and the corresponding file name and port number in the next step. Make sure that you log in to the VNC server with the user name you used to configure the VNC password .

The VNC service itself is using port 5900. Given that different users are using VNC, each person's connection will be given a different port. The number in the profile name tells the VNC server to run the service on a 5900 sub-port. In our example, the first VNC service will run on a 5901 (5900 + 1) port, followed by an increase in order, running on the 5900 + x port. where x refers [email protected]:x.service to the x within the user's profile name.

Before establishing a connection, we need to know the IP address and port of the server. An IP address is a unique identification number for a computer in the network. The IP address of my server is the 96.126.120.92,VNC user port is 1.

Execute the following command to get the server's public IP address (LCTT): If your server is in the intranet or using a dynamic address, you can obtain its public IP address.

    1. # curl -s checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //‘ -e ‘s/<.*$//‘
Summarize

Okay, now we're in the???. The server on CentOS 7/rhel 7 is installed with a VNC server configured. VNC is one of the simplest tools in free-source software that enables remote control servers, and is an excellent alternative to Teamviewer remote Access. VNC allows a user with a VNC client installed to remotely control a server with a VNC service installed. There are also some frequently used related commands. Play well!

Other commands:
    • Turn off the VNC service.

      1. # systemctl stop [email protected]:1.service
    • Disable the VNC service from booting up.

      1. # systemctl disable [email protected]:1.service
    • Turn off the firewall.

      1. # systemctl stop firewalld.service

Installation configuration of VNC http://www.linuxidc.com/Linux/2013-05/84941.htm

CentOS 6.3 Installing and configuring VNC http://www.linuxidc.com/Linux/2013-05/84668.htm

Linux under force does not detect dependent installation VNC http://www.linuxidc.com/Linux/2013-05/84075.htm

CentOS6 VNC Service installation configuration http://www.linuxidc.com/Linux/2013-04/82510.htm

VNC Configuration and Installation http://www.linuxidc.com/Linux/2013-05/83975.htm under CentOS

VNC Remote Control installation and Setup http://www.linuxidc.com/Linux/2013-01/77769.htm

Windows access Ubuntu http://www.linuxidc.com/Linux/2012-10/73043.htm via VNC

Windows Remote Desktop access Ubuntu 12.04 installation VNC http://www.linuxidc.com/Linux/2012-07/64801.htm

For more information on CentOS, see the CentOS feature page http://www.linuxidc.com/topicnews.aspx?tid=14

This article permanently updates the link address : http://www.linuxidc.com/Linux/2015-04/116725.htm

How to install and configure a VNC server on CentOS 7.0

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.