本文环境为 Arch Linux
环境依赖
编译环境
官方编译文档
- cmake (v3.10 or later)
- zlib
- pixman
- FLTK (v1.3.3 or later)
- GnuTLS (v3.x or later)
- Nettle (v3.0 or later)
- gettext (Gnu v0.14.4 or later)
- libjpeg-turbo
- PAM
- ffmpeg
额外补充
- xorg-server-devel
- xorg-xauth
- xorg-xinit
- xorg-xkbcomp
- xorg-xrandr
- xorg-xrdb
- xorg-iceauth
- xorg-font-util
- xtrans
图形环境
桌面环境 (xfce)
- 安装
xfce4
软件组 - 新建/编辑
~/.xinitrc
,加入exec startxfce4
References:
Xorg
安装 xorg-server
软件包
xorg-apps
或 xorg
软件组不需要安装,按需选择
References:
编译安装
拉取 TigerVNC 源码
git clone https://github.com/TigerVNC/tigervnc.git
准备 Xorg server 源码
注意不是 Git 仓库源码,而是某些 Linux 发行版所发布的源码软件包,如 Debian 系:
http://deb.debian.org/debian/pool/main/x/xorg-server/xorg-server_21.1.4.orig.tar.gz
将解压出的 Xorg server 源码复制到
.../tigervnc/unix/xserver/
目录下rsync -a .../xorg-server-21.1.4/ .../tigervnc/unix/xserver
编辑
.../tigervnc/CMakeLists.txt
,根据个人需求启用或关闭option
项。如禁用 TigerVNC Viewer 的编译于 TigerVNC 源码根目录下执行 make 操作
cmake . make -j2
进入
.../tigervnc/unix/xserver
,打上最新补丁patch -p1 < ../xserver{version}.patch
编译安装 (./configure 选项根据系统情况进行修改)
autoreconf -fiv ./configure --with-pic --without-dtrace --disable-static --disable-dri --disable-xinerama --disable-xvfb \ --disable-xnest --disable-xorg --disable-dmx --disable-xwin --disable-xephyr --disable-kdrive \ --disable-config-dbus --disable-config-hal --disable-config-udev --disable-dri2 \ --enable-install-libxf86config --enable-glx \ --with-xkb-path=/usr/share/X11/xkb --with-xkb-output=/var/lib/xkb \ --with-xkb-bin-directory=/usr/bin --with-serverconfig-path=/usr/lib64/xorg \ --with-dri-driver-path=/usr/lib64/dri make -j2 TIGERVNC_SRCDIR=.../tigervnc sudo make install
如上,未更改程序安装路径,默认安装路径为
/usr/local/...
问题修复
编辑
/usr/local/etc/pam.d/tigervnc
,注释掉pam_selinux.so
行#%PAM-1.0 # pam_selinux.so close should be the first session rule #-session required pam_selinux.so close session required pam_loginuid.so #-session required pam_selinux.so open session required pam_namespace.so session optional pam_keyinit.so force revoke session required pam_limits.so -session optional pam_systemd.so session required pam_unix.so -session optional pam_reauthorize.so prepare
将该文件移动/复制到
/etc/pam.d/
路径下sudo mv /usr/local/etc/pam.d/tigervnc /etc/pam.d/
编辑
/usr/local/lib/systemd/system/vncserver@.service
,移除selinux
相关... #SELinuxContext=system_u:system_r:vnc_session_t:s0 ...
使用
初始化 VNC 连接密码
vncpasswd
密码将被保存在
~/.vnc/passwd
编辑
/usr/local/etc/tigervnc/vncserver.users
创建用户会话映射:1={user}
:1
代表 TCP port 5901 (5900+1)创建
~/.vnc/config
文件session=xfce geometry=1920x1080 localhost alwaysshared
session
指定运行的桌面环境,可以查看/usr/share/xsessions
路径下的.desktop
文件来确定系统上已经存在的桌面环境如
xfce.desktop
,则session
可指定为session=xfce
设置 VNC Server 开机自启动
sudo systemctl enable --now vncserver@:1.service
:1
与前面的用户会话映射相对应通过 SSH Tunnel 加密 VNC 连接 (客户端)
ssh -fL 9901:localhost:5901 {host} sleep 10
References:
其他
可能需要一个 dm (display manager)。应该不需要,但若是按步骤安装完成后有问题不能用,可以试试。常见的有:
- sddm (推荐,功能)
- xdm
- gdm
- lightdm (推荐,轻量) + lightdm-xxx-greeter (参见 ArchWiki)
以 lightdm 为例,将
/etc/lightdm/Xsession
软链接到/etc/X11/Xsession
或/etc/X11/xinit/Xsession
sudo ln -sf /etc/lightdm/Xsession /etc/X11/xinit/Xsession
可能需要赋予
~/.xinitrc
可执行权限chmod +x ~/.xinitrc
References: