Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to quickly install a VNC server

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to quickly install the VNC server, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Overview of vnc service: abbreviation for VNC (Virtual Network Computing) virtual network computer, mainly to complete the remote control of the graphical interface. A vnc system is composed of a client, a server and a protocol. The server is to share its screen, the client is to control the server screen, and the protocol (RFB) is to transmit the original image of the server to the client and send events to the server.

1. Install X-Window

First we need to install X-Window, run the following command in the terminal, and the installation will take some time.

# yum check-update# yum groupinstall "X Window System" # yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts### settings launch the graphical interface by default # 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 are going to install the VNC server on the server.

two。 Install the VNC server

Now it's time to install the VNC server on our CentOS 7. We need to carry out the following orders.

# yum install tigervnc-server-Y3. Configure VNC

Then we need to create a configuration file in the / etc/systemd/system/ directory. We can copy a sample configuration file of / lib/systemd/sytem/vncserver@.service.

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

Then we open / etc/systemd/system/vncserver@:1.service with our favorite editor (the nano we use here), find the following lines, and replace them with our user name. For example, my user name is linoxide, so I replace it with linoxide:

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

Replace with

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

If it is a root user,

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

All right, let's restart systemd.

# systemctl daemon-reload

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

# su linoxide$ sudo vncpasswd

Note: make sure that the password you enter is more than 6 characters

4. Start the service

Start the service (permanently) with the following command:

$sudo systemctl enable vncserver@:1.service

Start the service.

$sudo systemctl start vncserver@:1.service5. Firewall Settin

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

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

You can now connect to the VNC server using IP and port number (for example, 192.168.1.1 LCTT 1, where the port is not the server's port, but sorted from 1 depending on the number of VNC connections).

6. Connect to the server with a VNC client

Well, the installation of the VNC server is now complete. To connect to the server using VNC, we also need a VNC client installed on the local computer for connecting to the remote computer only.

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

To connect with more users, you need to create a profile and port, go back to step 3 and add a new user and port. You need to create a vncserver@:2.service and replace the user name in the configuration file and the corresponding file name and port number in the subsequent steps. Please make sure that you log in to the VNC server with the same user name you used when you configured your VNC password.

The VNC service itself uses port 5900. Given that different users use VNC, everyone will get a different port for their connection. The number in the configuration file name tells the VNC server to run the service on subport 5900. In our example, the first VNC service will run on port 5901 (5900 + 1), and then increase in turn, running on port 5900 + x. Where x is the x in the user's profile name vncserver@:x.service.

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.92jue VNC user port is 1.

Execute the following command to get the public IP address of the server (LCTT: if your server is placed on the intranet or uses a dynamic address, you can get its public IP address).

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

Other commands:

Shut down the VNC service.

# systemctl top vncserver@:1.service

Disable the VNC service from booting.

# systemctl disable vncserver@:1.service

Turn off the firewall.

# systemctl stop firewalld.service Thank you for reading this article carefully. I hope the article "how to install VNC Server quickly" shared by the editor will be helpful to you. At the same time, I hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report