How to install and configure a VNC Server on CentOS 7.0

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

How to install and configure a VNC Server on CentOS 7.0

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

As we all know, as a system administrator, servers are managed over the network most of the time. The graphic interface is rarely used in server management. In most cases, we only use SSH to complete our management tasks. In this article, we will configure VNC to provide a method to connect to our CentOS 7 server. VNC allows us to enable a remote graphic session to connect to our server, so that we can remotely access the server's graphical interface through the network.

VNC Server is a free and open source software that allows users to remotely access the desktop environment of the server. In addition, you must use the VNC viewer client to connect to the VNC server.

Advantages of some VNC servers:

  • Remote graphical management makes work easy and convenient.
  • The clipboard can be shared between the CentOS server host and the VNC client host.
  • You can also install graphical tools on the CentOS server to make management more powerful.
  • Once the VNC client is installed, you can use any operating system to manage the CentOS server.
  • It is more reliable than ssh graphic forwarding and RDP connections.

So, let's get started with VNC Server installation. Follow the steps below to build an available VNC.

First, we need an available desktop environment (X-Window). If not, we need to install one first.

Note: The following commands must be run as root. To switch to the root user, Run "sudo-s" on the terminal, excluding double quotation marks ("").

1. install X-Window

First, we need to install X-Window and run the following command on the terminal. It takes a little time to install X-Window.

  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. ### Set the default startup Gui
  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 is restarted, we have a working CentOS 7 desktop environment.

Now we have to install the VNC server on the server.

2. Install the VNC Server

Now we have to install the VNC Server on CentOS 7. We need to execute the following command.

  1. # yum install tigervnc-server -y

3. Configure VNC

Then, we need/etc/systemd/system/Create a configuration file in the directory. We can/lib/systemd/sytem/vncserver@.serviceCopy a configuration file example.

  1. # cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

Then we use our favorite editor (Here we use nano) to open/etc/systemd/system/vncserver@:1.serviceFind the following lines and replace them with your username. For example, my user name is linoxide, So I replaced it with linoxide:

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

Replace

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

For root users

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

Now, restart systemd.

  1. # systemctl daemon-reload

Finally, you must set the user's VNC password. To set a password for a user, you must have the permission to switch to the user through sudo. Here, I use the permission of linoxide to execute"su linoxide.

  1. # su linoxide
  2. $ sudo vncpasswd

Make sure that you enter more than 6 Characters in the password

4. enable the Service

Run the following command (permanently) to enable the Service:

  1. $ sudo systemctl enable vncserver@:1.service

Start the service.

  1. $ sudo systemctl start vncserver@:1.service
5. Firewall settings

We need to configure a firewall to make the VNC service work normally.

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

Now you can use the IP address and port number (for example, 192.168.1.1: 1). The port here is not the server port, but is sorted from 1 according to the number of VNC connections) to connect to the VNC server.

6. Use a VNC client to connect to the server

Now the VNC server has been installed. To connect to the server using VNC, we also need a VNC client installed on the local computer that is only used to connect to the remote computer.

You can use clients like Tightvnc viewer and Realvnc viewer to connect to the server.

To use more user connections, you need to create a configuration file and port. Go Back To Step 1 and add a new user and port. You need to createvncserver@:2.serviceReplace the username in the configuration file and the corresponding file name and port number in the subsequent steps. Make sure that you log on to the VNC server using the user name you used when configuring the VNC password.

The VNC service uses the port 5900. Given that different users use VNC, different ports are obtained for each connection. The number in the configuration file name tells the VNC server to run the service on the sub port 5900. In this example, the first VNC service runs on port 5901 (5900 + 1), increases in sequence, and runs on port 5900 + x. X indicates the user's configuration file name.vncserver@:x.serviceX.

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

Run the following command to obtain the Internet IP address of the server (LCTT: If your server is placed on the Intranet or uses a dynamic IP address, you can obtain its Internet IP address ).

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

Now we have installed and configured the VNC server on the server running CentOS 7/RHEL 7. VNC is the simplest tool for free open-source software to remotely control servers. It is also an excellent substitute for Teamviewer Remote Access. VNC allows a user installed with a VNC client to remotely control a server installed with the VNC service. The following are some frequently used commands. Have fun!

Other commands:
  • Disable the VNC service.

    1. # systemctl stop vncserver@:1.service
  • Disable VNC service startup.

    1. # systemctl disable vncserver@:1.service
  • Disable the firewall.

    1. # systemctl stop firewalld.service

VNC installation Configuration

Install and configure VNC in CentOS 6.3

In Linux, the dependency installation VNC is not detected.

CentOS6 VNC service installation and configuration

Configure and install VNC in CentOS

VNC remote control installation and Setup

Windows accesses Ubuntu through VNC

Install VNC for accessing Ubuntu 12.04 through Windows Remote Desktop

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.