VNC 部署

环境

os: centos7.9
hw: X86-64

介绍

tigervnc 和 tightvnc 区别

特性 TigerVNC TightVNC
历史和开发 由 Red Hat 公司开发,基于 TightVNC 代码 由 Constantin Kaplinsky 开发
支持的平台 Windows、Linux、Mac OS X、Android、iOS 等 Windows、Linux
性能 经过优化,提供更流畅的体验 性能也很好,但在某些情况下可能不如 TigerVNC
安全性 支持更多安全选项,例如 TLS 加密和 SSH 隧道 支持一些安全选项,但不如 TigerVNC 丰富
其他功能 支持 Java 客户端和 Web 浏览器访问 支持 ActiveX 控件和 RDP 协议

Kali Linux 上默认使用 TightVNC 1.3.10版本.
License原因, 只能下载旧版本的tightvnc, 所以我们选择 tigerVNC.
图

一、 rpm部署tigerVNC

1.1 安装

yum install tigervnc-server -y

1.2 配置 service

复制配置文件:
cp /usr/lib/systemd/system/[email protected] /etc/systemd/system/[email protected]

修改: vim /etc/systemd/system/[email protected]
41行: <USER> –> 实际用户
生效: systemctl daemon-reload

1.3 配置 vnc 密码

vncpasswd

1.4 启动 vnc

要启动并启用服务,请在 命令中直接指定显示号。以上 为单个用户配置 VNC 显示 中配置的文件作为模板运行,其中 %i 被 systemd 替换为显示号。使用有效的显示号,执行以下命令:

systemctl start vncserver@:display_number.service

这里面我们实际运行: systemctl start vncserver@:3.service
可以看到相关服务和端口都起来了
图

1.5 多用户配置

配置两个 VNC 服务器,[email protected][email protected],可以启用不同的显示号。例如,以下命令将 USER_1 的 VNC 服务器在桌面 3 中启动, USER_2 的 VNC 服务器在桌面 5 中启动:

su 切换到用户, 执行 vncpassword 后使用

~]# systemctl start vncserver-USER_1@:3.service
~]# systemctl start vncserver-USER_2@:5.service

1.6 关闭 vnc 服务

systemctl disable vncserver@:1.service

1.7 相关问题 “A VNC server is already running as :1”

rm -rf /tmp/.X0-lock
rm -rf /tmp/.X11-unix/X0

二、 源码部署tigerVNC (适用于大部分 GNU/Linux)

2.0 依赖

yum install cmake zlib pixman fltk libjpeg-turbo

引用文档: 注意以下包的版本

================================
Build Requirements (All Systems)
================================

-- CMake (http://www.cmake.org) v3.10 or later
-- zlib
-- pixman
-- FLTK 1.3.3 or later
-- If building TLS support:
* GnuTLS 3.x
* See "Building TLS Support" below.
-- If building RSA-AES support:
* Nettle 3.0 or later
-- If building native language support (NLS):
* Gnu gettext 0.14.4 or later
* See "Building Native Language Support" below.
-- libjpeg-turbo
* "Normal" libjpegv6 is also supported, although it is not
recommended as it is much slower.

2.1 下载

https://github.com/TigerVNC/tigervnc/releases

2.2 解压

tar -xzvf tigervnc-1.13.1.tar.gz

2.3 tigerVNC-server 编译