Rules for installing and configuring a VNC server

Source: Internet
Author: User
Tags centos server tightvnc viewer

Guide 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, in most cases we just use SSH to complete our management tasks. 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 quotation marks ("").

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.

# yum check-update# yum groupinstall "X window System"

#yum Install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts

# # # Set Default start graphical interface # unlink/etc/systemd/system/default.target# ln-sf/lib/systemd/system/graphical.target/etc/systemd/ System/default.target

# 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.

# yum Install tigervnc-server-y

3. Configuring VNC

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

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

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

Execstart=/sbin/runuser-l <USER>-C "/usr/bin/vncserver%i" pidfile=/home/<user>/.vnc/%h%i.pid

Replaced by

Execstart=/sbin/runuser-l linoxide-c "/usr/bin/vncserver%i" pidfile=/home/linoxide/.vnc/%h%i.pid

If it is the root user

Execstart=/sbin/runuser-l root-c "/usr/bin/vncserver%i" pidfile=/root/.vnc/%h%i.pid

OK, here's the restart SYSTEMD.

# 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" can be.

# su linoxide$ sudo vncpasswd

Note: Make sure you enter a password that is more than 6 characters

4. Turn on the service

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

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

Start the service.

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

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

$ sudo firewall-cmd--permanent--add-service vnc-server$ 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 with 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 to the user's profile name after the [email Protected]:x.service x.

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.

# curl-s Checkip.dyndns.org|sed-e ' s/.*current IP Address://'-E ' s/<.*$//'
Other Commands:

Turn off the VNC service.

# systemctl Top [email protected]:1.service

Disable the VNC service from booting up.

# systemctl Disable [email protected]:1.service

Turn off the firewall.

# Systemctl Stop Firewalld.service
Summary

OK, now we have the VNC server installed on the server running CentOS 7/rhel 7. 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.

Rules for installing and configuring a VNC server

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.