使用tigervnc通过vnc协议远程控制Centos8

安装桌面环境

如果没有桌面环境需要先安装桌面环境,通过如下命令安装:

# dnf groupinstall "workstation"

或者

# dnf groupinstall "Server with GUI"

设置默认启动桌面环境

# systemctl set-default graphical

安装VNC Server

需要再受控端也就是受控的Centos8系统安装VNC Server服务,命令如下:

# dnf install tigervnc-server tigervnc-server-module -y

切换不同的用户可执行如下命令可不同用户的设置password,输入两边。

# vncpasswd

出现如下提示:Would you like to enter a view-only password (y/n)? n
意思是询问你是否建立一个观察密码,就是只能看不能操作的密码,我们这里不设置。选择n
配置完成后再主文件目录下.vnc文件夹下可以看到我们配置的密码。

配置VNC用户及基本配置

执行如下命令进行用户配置,指的是用于远程登录Centos的用户:

# vim /etc/tigervnc/vncserver.users
# TigerVNC User assignment
#
# This file assigns users to specific VNC display numbers.
# The syntax is <display>=<username>. E.g.:
#
# :2=andrew
# :3=lisa
:1=root

跟据实例新增如下 :1=root含义是1指的是使用5901端口进行root用户登录访问
执行如下命令,进行默认设置如下,登录gnome窗体,窗体区域800*600

# vim /etc/tigervnc/vncserver-config-defaults
## Default settings for VNC servers started by the vncserver service
#
# Any settings given here will override the builtin defaults, but can
# also be overriden by ~/.vnc/config and vncserver-config-mandatory.
#
# See the following manpages for more details: vncserver(1) Xvnc(1)
#
# Several common settings are shown below. Uncomment and modify to your
# liking.

# securitytypes=vncauth,tlsvnc
# desktop=sandbox
# geometry=2000x1200
# localhost
# alwaysshared
session=gnome
geometry=800x600

启动服务

启动服务

# systemctl start  vncserver@:1.service

加入到开机自启

# systemctl enable  vncserver@:1.service

防火墙配置

# firewall-cmd --permanent --add-port=5901/tcp
# firewall-cmd --reload

注意:

这里需要关闭selinux才行否则连接失败

vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

备注:Centos8和7不太一样,不需要复制等其他设置
如:

sudo cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@.service

然后修改内容等

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值