How to install vnc on centos

青灯夜游
Release: 2021-03-18 17:01:14
Original
10706 people have browsed it

Method: 1. Use the "yum install..." command to install the VNC service software; 2. Edit the vnc operation script; 3. Set the vnc password and start the service; 4. Open the 5901 port of the firewall; 5. Turn off SELinux and configure the "/etc/selinux/config" file.

How to install vnc on centos

#The operating environment of this tutorial: centos7 system, thinkpad t480 computer.

VNC requires a desktop installed on the system. If it is a production environment server and a minimal installation is used during installation, then perform the following operations according to the GNOME desktop.

# 列出的组列表里有GNOME Desktop。 yum grouplist #安装之 yum groupinstall -y "GNOME Desktop" # 安装完成后,修改默认启动方式为图形化界面 systemctl set-default graphical.target //设置成图形模式 # 如果要换回来 systemctl set-default multi-user.target //设置成命令模式 #然后重启系统即可
Copy after login

Step 1: Install the VNC service software, use the root user to execute the following commands (the following operations are performed under the root user unless otherwise specified):

yum install tigervnc-server -y
Copy after login

After installation, you can use the following command to verify whether the installation is successful:

rpm -qa|grep tigervnc-server
Copy after login

##Step 2: Copy the startup operation script of vnc, in vncserver@:1.service: 1 means "desktop number", the started port number is 5900, the desktop number is 5901, if there is another one, it is 2, the port number plus 1 is 5902, and so on:

cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Copy after login

Step 3: Edit /etc/systemd/system/vncserver@:1.service

vim /etc/systemd/system/vncserver@\:1.service
Copy after login

vnc configuration file before modification
Find and change it to your own username. If the root user logs in to the desktop, use the root user. If you use an ordinary user to log in to the desktop, use an ordinary user. Here I use the username: cy

After modifying the vnc configuration file
After modification, save and exit vim.

Step 4: Set the vnc password, execute su cy, switch to the cy user just set in the configuration file, execute (this step is performed under the cy user), enter the password twice , after the input is completed, you will be prompted whether to set the view-only password ("View-onlypassword" password,only allows viewing, no control permissions.) This can be set or not:

vncpasswd
Copy after login

Step 5: Start the service:

systemctl start vncserver@\:1.service
Copy after login

You may be asked to enter the start service command for the first time (reload the configuration file , you need to execute the daemon-reload subcommand when adding new files or changing configuration files):

systemctl daemon-reload
Copy after login

After the execution is completed, just execute the startup command:

You can add it to boot, and it will start automatically next time you boot:

systemctl enable vncserver@\:1.service
Copy after login

Step 6: Check whether the port is listening:

netstat -lnpt|grep Xvnc
Copy after login

Here we can see that port 5901 has been monitored

Step 7: Open the 5901 port of the firewall:

firewall-cmd --zone=public --add-port=5901/tcp --permanent
Copy after login

If the firewall is not started, it needs to be started first Firewall.

Of course, you can also be more ruthless and stop the firewall directly:

systemctl stop firewalld.service
Copy after login

After stopping, you need to disable booting:

systemctl disable firewalld.service
Copy after login

Step 8: Turn off SELinux and edit the /etc/selinux/config file:

vim /etc/selinux/config
Copy after login

Set selinux to disabled

Now that the vnc service has been installed, you can use the vnc client to connect.

Step 9: Enter the server IP:desktop number (such as 192.168.31.100:1) in the vnc client (vnc viewer), and press Enter after input:

Step 10: After entering the IP, a confirmation will pop up, click contiue:

Step 11: Enter the vnc password:

# #Step 12: Log in successfully, enter the password of the remote machine (after successful login, you need to enter the password of the user of the remote machine, if you do not have a password, you can enter the system directly):

Step 13: Successfully enter the remote desktop:

The entire CentOS7.x VNC service is now installed^_^.

Tips: The vnc service can only be used on the LAN. If it is on the external network, you need a public IP address. VNC not only has the internal network penetration function.

Recommended related tutorials:

centos tutorial

The above is the detailed content of How to install vnc on centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!