5. 远程桌面
本章主要讲解如何使用远程桌面连接LubanCat
5.1. VNC
VNC(Virtual Network Console)是虚拟网络控制台的缩写。 它是一款优秀的远程控制工具软件,由著名的AT&T的欧洲研究实验室开发。
5.1.1. 配置鲁班猫VNC服务
VNC分为客户端和服务端,我们首先进行鲁班猫上服务端的配置。
5.1.1.1. 安装VNC服务
sudo apt install x11vnc
5.1.1.2. 创建连接密码
x11vnc -storepasswd
使用cat用户创建VNC连接密码,密码默认保存在/home/cat/.vnc/passwd文件中
5.1.1.3. 进行连接测试
export DISPLAY=:0
x11vnc -auth guess -once -loop -noxdamage -repeat -rfbauth /home/cat/.vnc/passwd -rfbport 5900 -shared
手动开启VNC服务,设置连接端口为5900,如果端口被占用可以使用其他端口。
开启VNC服务以后,我们使用MobeXterm的VNC连接功能进行测试
5.1.1.4. 设置VNC服务开机自启动
sudo vim /etc/systemd/system/x11vnc.service
新建文件,创建一个x11vnc.service的服务,在文件中输入以下内容
[Unit]
Description=x11vnc (Remote access)
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -display :0 -rfbauth /home/cat/.vnc/passwd -rfbport 5900 -forever -loop -noxdamage -repeat -shared -capslock -nomodtweak
ExecStop=/bin/kill -TERM $MAINPID
ExecReload=/bin/kill -HUP $MAINPID
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=graphical.target
文件创建成功以后,使用以下命令重新读取系统服务配置,将x11vnc.service加入系统服务并开启
sudo systemctl daemon-reload
sudo systemctl enable x11vnc
sudo systemctl start x11vnc
vncserver -geometry 1366x768 -alwaysshared -depth 24 -dpi 96 :1 -localhost no
错误:连不上
12/04/2024 16:18:56 -usepw: found /home/cat/.vnc/passwd
12/04/2024 16:18:56 x11vnc version: 0.9.16 lastmod: 2019-01-05 pid: 3202
12/04/2024 16:18:56 Using X display :0.0
12/04/2024 16:18:56 rootwin: 0x53b reswin: 0x4800001 dpy: 0x8e7a29a0
12/04/2024 16:18:56
12/04/2024 16:18:56 ------------------ USEFUL INFORMATION ------------------
12/04/2024 16:18:56 X DAMAGE available on display, using it for polling hints.
12/04/2024 16:18:56 To disable this behavior use: '-noxdamage'
12/04/2024 16:18:56
12/04/2024 16:18:56 Most compositing window managers like 'compiz' or 'beryl'
12/04/2024 16:18:56 cause X DAMAGE to fail, and so you may not see any screen
12/04/2024 16:18:56 updates via VNC. Either disable 'compiz' (recommended) or
12/04/2024 16:18:56 supply the x11vnc '-noxdamage' command line option.
12/04/2024 16:18:56
12/04/2024 16:18:56 Wireframing: -wireframe mode is in effect for window moves.
12/04/2024 16:18:56 If this yields undesired behavior (poor response, painting
12/04/2024 16:18:56 errors, etc) it may be disabled:
12/04/2024 16:18:56 - use '-nowf' to disable wireframing completely.
12/04/2024 16:18:56 - use '-nowcr' to disable the Copy Rectangle after the
12/04/2024 16:18:56 moved window is released in the new position.
12/04/2024 16:18:56 Also see the -help entry for tuning parameters.
12/04/2024 16:18:56 You can press 3 Alt_L's (Left "Alt" key) in a row to
12/04/2024 16:18:56 repaint the screen, also see the -fixscreen option for
12/04/2024 16:18:56 periodic repaints.
12/04/2024 16:18:56
12/04/2024 16:18:56 XFIXES available on display, resetting cursor mode
12/04/2024 16:18:56 to: '-cursor most'.
12/04/2024 16:18:56 to disable this behavior use: '-cursor arrow'
12/04/2024 16:18:56 or '-noxfixes'.
12/04/2024 16:18:56 using XFIXES for cursor drawing.
12/04/2024 16:18:56 GrabServer control via XTEST.
12/04/2024 16:18:57
12/04/2024 16:18:57 Scroll Detection: -scrollcopyrect mode is in effect to
12/04/2024 16:18:57 use RECORD extension to try to detect scrolling windows
12/04/2024 16:18:57 (induced by either user keystroke or mouse input).
12/04/2024 16:18:57 If this yields undesired behavior (poor response, painting
12/04/2024 16:18:57 errors, etc) it may be disabled via: '-noscr'
12/04/2024 16:18:57 Also see the -help entry for tuning parameters.
12/04/2024 16:18:57 You can press 3 Alt_L's (Left "Alt" key) in a row to
12/04/2024 16:18:57 repaint the screen, also see the -fixscreen option for
12/04/2024 16:18:57 periodic repaints.
12/04/2024 16:18:57
12/04/2024 16:18:57 XKEYBOARD: number of keysyms per keycode 7 is greater
12/04/2024 16:18:57 than 4 and 51 keysyms are mapped above 4.
12/04/2024 16:18:57 Automatically switching to -xkb mode.
12/04/2024 16:18:57 If this makes the key mapping worse you can
12/04/2024 16:18:57 disable it with the "-noxkb" option.
12/04/2024 16:18:57 Also, remember "-remap DEAD" for accenting characters.
12/04/2024 16:18:57
12/04/2024 16:18:57 X FBPM extension not supported.
12/04/2024 16:18:57 X display is capable of DPMS.
12/04/2024 16:18:57 --------------------------------------------------------
12/04/2024 16:18:57
12/04/2024 16:18:57 Default visual ID: 0x21
12/04/2024 16:18:57 Read initial data from X display into framebuffer.
12/04/2024 16:18:57 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/7680
12/04/2024 16:18:57
12/04/2024 16:18:57 X display :0.0 is 32bpp depth=24 true color
12/04/2024 16:18:57
12/04/2024 16:18:57 Autoprobing TCP port
12/04/2024 16:18:57 Autoprobing selected TCP port 5900
12/04/2024 16:18:57 Autoprobing TCP6 port
12/04/2024 16:18:57 Autoprobing selected TCP6 port 5900
12/04/2024 16:18:57 listen6: bind: Address already in use
12/04/2024 16:18:57 Not listening on IPv6 interface.
12/04/2024 16:18:57
12/04/2024 16:18:57 Xinerama is present and active (e.g. multi-head).
12/04/2024 16:18:57 Xinerama: number of sub-screens: 1
12/04/2024 16:18:57 Xinerama: no blackouts needed (only one sub-screen)
12/04/2024 16:18:57
12/04/2024 16:18:57 fb read rate: 90 MB/sec
12/04/2024 16:18:57 fast read: reset -wait ms to: 10
12/04/2024 16:18:57 fast read: reset -defer ms to: 10
12/04/2024 16:18:57 The X server says there are 10 mouse buttons.
12/04/2024 16:18:57 screen setup finished.
12/04/2024 16:18:57
The VNC desktop is: lubancat:0
PORT=5900
******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?
The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval. It should work with any VNC viewer. Try it by running:
x11vnc -ncache 10 ...
One can also add -ncache_cr for smooth 'copyrect' window motion.
More info: http://www.karlrunge.com/x11vnc/faq.html#faq-client-caching