使用 x11vnc 为树莓派开启远程桌面

0x00 前言

此前,有许多诸如 tightvncrealvnc 等工具的教程帮助树莓派启动 vnc 服务,至少通过关键词【树莓派 vnc】最为搜索条件的结果是这样子的。他们都有一个共同的特点:虚拟桌面会话,也就是说远程 vnc 看到的桌面并非真实桌面(即物理显示器显示的桌面),而是为每个用户创建了一个虚拟的桌面,每个桌面之间互不干扰。但是 x11vnc 却与众不同,这个工具能够让你像 Windows RDP 一样访问现有的 session,而不是新建或虚拟出一个桌面。
除了能够访问真实桌面之外,我认为还有一个让我很满意的地方:兼容性强且操作简便 。相信绝大多数树莓派使用者都会遇到一个问题 【VNC 灰屏】,一般情况下解决方法是修改~/.vnc/xstartup 文件,该文件是 VNC 的图形配置文件,用户需要明确当前系统的桌面环境,才具备更改的能力,如果按照网上给的 xstartup 内容复制粘贴,因为桌面环境的差异,可能依旧还是老问题。但是使用 x11vnc 的话,显然就没有这么麻烦了。下面是 kali-rpi 下配置 x11vnc 环境的教程:

0x01 我的系统环境

968bc2b31526885d78053b56a141789e.png

0x02 配置方法

安装 x11vnc 工具

1
root@kali:~# apt install -y x11vnc

更改镜像显示的参数 framebuffer

  1. 使用 nanovim打开 /boot/config.txt
  2. config.txt 取消文件中下列配置的注释:

改前:

1
2
#framebuffer_width=1280
#framebuffer_height=720

改后:

1
2
framebuffer_width=1280
framebuffer_height=720

  1. 重启树莓派
  2. 设置密码
1
root@kali:~# x11vnc -storepasswd

密码文件默认保存在~/.vnc/passwd.
可在 storepasswd 之后指定密码文件的路径。

设置自启

新建/lib/systemd/system/x11vnc.service

1
2
3
4
5
6
7
8
9
10
[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=x11vnc -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -o /var/log/x11vnc.log -rfbport 5900 -rfbauth ~/.vnc/passwd -loop

[Install]
WantedBy=multi-user.target

设置服务开机自启

1
2
3
root@kali:~# systemctl daemon-reload
root@kali:~# systemctl enable x11vnc.service
root@kali:~# systemctl start x11vnc.service

如果没有 -loop 参数,在使用 systemctl 会导致服务启动失败。

0x03 相关软件工具

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
tightvnc-java - TightVNC java applet and command line program
vnc-java - VNC java applet and command line program
archipel-agent-virtualmachine-vnc - Virtual Machine Orchestration (Agent Virtualmachine VNC)
autocutsel - Keep the X clipboard and the cutbuffer in sync
avahi-ui-utils - Avahi GTK+ utilities
chaosreader - trace network sessions and export it to html format
conspy - Remote control of Linux virtual consoles
directvnc - VNC client using the framebuffer as display
dmtcp - Checkpoint/Restart functionality for Linux processes
dmtcp-dbg - Debug package for dmtcp
gitso - simple frontend for reverse VNC connections (remote assistance)
gnome-rdp - remote desktop client for GNOME
gir1.2-gtk-vnc-2.0 - GObject introspection data for GTK-VNC.
gvncviewer - VNC viewer using gtk-vnc
libgtk-vnc-1.0-0 - VNC viewer widget for GTK+2 (runtime libraries)
libgtk-vnc-1.0-0-dbg - VNC viewer widget for GTK+2 (debugging symbols)
libgtk-vnc-1.0-dev - VNC viewer widget for GTK+2 (development files)
libgtk-vnc-2.0-0 - VNC viewer widget for GTK+3 (runtime libraries)
libgtk-vnc-2.0-0-dbg - VNC viewer widget for GTK+3 (debugging symbols)
libgtk-vnc-2.0-dev - VNC viewer widget for GTK+3 (development files)
libgvnc-1.0-0 - VNC gobject wrapper (runtime libraries)
libgvnc-1.0-0-dbg - VNC gobject wrapper (debugging symbols)
libgvnc-1.0-dev - VNC GObject wrapper (development files)
python-gtk-vnc - VNC viewer widget for GTK+2 (Python binding)
guacamole-tomcat - Tomcat-based Guacamole install with VNC support
guacd - Guacamole proxy daemon
libguac-client-vnc0 - VNC support plugin for Guacamole
hydra - very fast network logon cracker
hydra-gtk - very fast network logon cracker - GTK+ based GUI
libsvnqt7 - Qt wrapper library for Subversion
krdc - Remote Desktop Connection client
krdc-dbg - Remote Desktop Connection client debugging symbols
krfb - Desktop Sharing utility
libnet-vnc-perl - Perl module implementing a simple VNC client
libvncclient0 - API to write one's own vnc server - client library
libvncclient0-dbg - debugging symbols for libvncclient
libvncserver-config - API to write one's own vnc server - library utility
libvncserver-dev - API to write one's own vnc server - development files
libvncserver0 - API to write one's own vnc server
libvncserver0-dbg - debugging symbols for libvncserver
linuxvnc - VNC server to allow remote access to a tty
nova-console - OpenStack Compute - console
nova-consoleproxy - OpenStack Compute - NoVNC proxy
novnc - HTML5 VNC client - daemon and programs
python-novnc - HTML5 VNC client - libraries
pagekite - Make localhost servers publicly visible.
pyvnc2swf - screen recording tool with Flash (SWF) output
libsvncpp-dev - Subversion C++ library (development files)
libsvncpp3 - Subversion C++ shayellow library
remmina - remote desktop client for GNOME desktop environment
remmina-plugin-vnc - VNC plugin for remmina remote desktop client
ssvnc - Enhanced TightVNC viewer with SSL/SSH tunnel helper
libsvnclientadapter-java - High-level Java API for Subversion (library)
libsvnclientadapter-java-doc - High-level Java API for Subversion (documentation)
tightvncserver - virtual network computing server software
xtightvncviewer - virtual network computing client software for X
vinagre - remote desktop client for the GNOME Desktop
vino - VNC server for GNOME
virt-manager - desktop application for managing virtual machines
virt-viewer - Displaying the graphical console of a virtual machine
vnc4server - Virtual network computing server software
xvnc4viewer - Virtual network computing client software for X
vncsnapshot - A utility that takes JPEG snapshots from VNC servers
vtgrab - A VNC like console monitoring
websockify - WebSockets support for any application/server
winswitch - tool to start and control remote sessions
x11vnc - VNC server to allow remote access to an existing X session
x11vnc-data - data files for x11vnc
x2vnc - Link a VNC and an X display together, simulating a multiheaded display
xorg-server-source - Xorg X server - source files
xpra - tool to detach/reattach running X programs
xpra-dbg - xpra -- debugging symbols
xrdp - Remote Desktop Protocol (RDP) server

0x04 参考





root@kali ~# cat 重要声明
本博客所有原创文章,作者皆保留权利。转载必须包含本声明,保持文本完整,并以超链接形式注明出处【Techliu】。查看和编写文章评论都需翻墙,为了更方便地获取文章信息,可订阅RSS,如果您还没有一款喜爱的阅读器,不妨试试Inoreader.
root@kali ~# Thankyou!