Lxn-Chan!

(~ ̄▽ ̄)→))* ̄▽ ̄*)o

通过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
    6
    PRETTY_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
    12
    root@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

  1. 安装x11vnc
    1
    apt update && apt install -y x11vnc
  2. 非root用户下设置VNC访问密码,请勿使用sudo执行
    1
    x11vnc -storepasswd
    输入两次密码后输入y确认保存。
  3. 启动测试共享:
    1
    x11vnc -display :0 -auth guess -forever -loop -noxdamage -rfbauth /home/lxnchan/.vnc/passwd
    此时使用任意VNC Viewer应该都能连接:

配置开机启动

写入systemd配置文件:/etc/systemd/system/x11vnc.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=x11vnc
After=display-manager.service graphical.target
Wants=display-manager.service

[Service]
Type=simple
User=lxnchan
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/lxnchan/.Xauthority
ExecStart=/usr/bin/x11vnc -display :0 -auth guess -forever -loop -noxdamage -rfbauth /home/lxnchan/.vnc/passwd
Restart=on-failure
RestartSec=5

[Install]
WantedBy=graphical.target

配置开机自动登录

编辑LightDM配置文件/etc/lightdm/lightdm.conf,找到[Seat:*]字段:

1
2
3
4
[Seat:*]
autologin-user=<username>
autologin-user-timeout=0
user-session=xfce

其中<username> 替换为你实际的用户名。

已知问题

连接后十秒内状态不正常

表现为连接成功后10秒钟内可能为黑屏、黑白格(RealVNC Viewer)、卡第一帧(tigerVNC Viewer),暂不清楚是什么问题。

 简单说两句



联系站长 | 服务状态 | 友情链接

备案号:辽ICP备19013963号

津公网安备12011602300394号

中国互联网违法和不良信息举报中心

架构版本号:8.1.8 | 本站已全面支持IPv6

正在载入运行数据(1/2)请稍后...
正在载入运行数据(2/2)请稍后...

O to die advancing on!

Copyright 2024 LingXuanNing, All rights reserved.