本文主要是介绍CentOS7安装tigervnc-server并启用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- CentOS7安装tigervnc-server并启用
yum install tigervnc-server -y
- 查看
/lib/systemd/system/vncserver@.service
cat /lib/systemd/system/vncserver@.service
- 里面详细描述了如何使用。
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Replace <USER> with the actual user name and edit vncserver
# parameters appropriately
# (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
# PIDFile=/home/<USER>/.vnc/%H%i.pid)
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.
-
共分为四个步骤:
- 将
/etc/systemd/system/vncserver@.service
文件拷贝为/etc/systemd/system/vncserver@:<display>.service
这里<display>
是表示第几个显示屏,可以设置为1。
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
- 将
<USER>
标识的字段,替换为用户名,例如root
,并正确修改vnc启动参数(ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i PIDFile=/home/<USER>/.vnc/%H%i.pid)"
vi /etc/systemd/system/vncserver@:1.service
- 运行
systemctl daemon-reload
systemctl daemon-reload
- 运行
systemctl enable vncserver@:<display>.service
,这里<display>
是表示第几个显示屏。
systemctl enable vncserver@:1.service
另外,它告诉我们不要在不受信任的网络上使用如上配置进行vnc访问。如果有需求,可以进行更多的配置,使用ssh等进行保护。
- 将
-
修改root访问vnc的密码
vncpasswd root
- 启动vncserver(注意,启动前最好关闭防火墙和selinux,否则可能会被策略阻挡导致无法连接上)
systemctl start vncserver@:1
- 关闭防火墙,selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vi /etc/selinux/config
修改enforcing
为disabled
- 启动后可以通过
systemctl status -l vncserver@:1
来查看vncserver服务的状态。
- 客户端下载
vnc-viewer
,realvnc
等软件,进行访问,通过ip:1
访问vnc服务端。
这篇关于CentOS7安装tigervnc-server并启用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!