通过VNC共享当前Debian的桌面
确认需求
本文所用x11vnc的功能是共享当前桌面的屏幕,类似RealVNC Server的效果;如果本身主机没有显示器、没有图形界面的话可参考在 armbian 上安装 xfce 和 VNC 做远程桌面。
当然也可以直接使用RealVNC Server。
环境介绍
- 内核版本:
1
Linux testbench 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64 GNU/Linux
- Debian版本:
1
2
3
4
5
6PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian - 会话管理器:
1
2
3
4
5
6
7
8
9
10
11
12root@testbench:~# systemctl status display-manager
● lightdm.service - Light Display Manager
Loaded: loaded (/lib/systemd/system/lightdm.service; enabled; preset: enabled)
Active: active (running) since Tue 2025-12-16 11:56:50 HKT; 3h 3min ago
Docs: man:lightdm(1)
Main PID: 644 (lightdm)
Tasks: 5 (limit: 38424)
Memory: 276.1M
CPU: 24min 30.667s
CGroup: /system.slice/lightdm.service
├─644 /usr/sbin/lightdm
└─658 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
部署远程桌面
安装并配置x11vnc
- 安装x11vnc
1
apt update && apt install -y x11vnc
- 在非root用户下设置VNC访问密码,请勿使用
sudo执行输入两次密码后输入1
x11vnc -storepasswd
y确认保存。 - 启动测试共享:此时使用任意VNC Viewer应该都能连接:
1
x11vnc -display :0 -auth guess -forever -loop -noxdamage -rfbauth /home/lxnchan/.vnc/passwd

配置开机启动
写入systemd配置文件:/etc/systemd/system/x11vnc.service
1 | [Unit] |
配置开机自动登录
编辑LightDM配置文件/etc/lightdm/lightdm.conf,找到[Seat:*]字段:
1 | [Seat:*] |
其中<username> 替换为你实际的用户名。
已知问题
连接后十秒内状态不正常
表现为连接成功后10秒钟内可能为黑屏、黑白格(RealVNC Viewer)、卡第一帧(tigerVNC Viewer),暂不清楚是什么问题。

