пятница, 15 ноября 2019 г.

Lubuntu 18.04. VNC подключение к сеансу пользователя

Задача:
Настроить возможность подключения в сеанс пользователя для оказания удаленной техподдержки.
Решение:
Ставим x11vnc
sudo apt install x11vnc -y
Генерируем пароль:
mkdir .vnc
x11vnc -storepasswd my_vnc_password ~/.vnc/x11vnc.pass
Для проверки запускаем от юзера:
x11vnc -rfbauth ~/.vnc/x11vnc.pass -noxdamage -shared -dontdisconnect -many -noxfixes
Должен получиться примерно такой вывод:
14/11/2019 17:19:30 passing arg to libvncserver: -rfbauth
14/11/2019 17:19:30 passing arg to libvncserver: /home/user/.vnc/x11vnc.pass
14/11/2019 17:19:30 passing arg to libvncserver: -dontdisconnect
14/11/2019 17:19:30 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 1014
14/11/2019 17:19:30 XOpenDisplay("") failed.
14/11/2019 17:19:30 Trying again with XAUTHLOCALHOSTNAME=localhost ...
14/11/2019 17:19:30 
14/11/2019 17:19:30 *** XOpenDisplay failed. No -display or DISPLAY.
14/11/2019 17:19:30 *** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
14/11/2019 17:19:30 *** 1 2 3 4 
14/11/2019 17:19:34 *** XOpenDisplay of ":0" successful.
14/11/2019 17:19:34 
14/11/2019 17:19:34 Using X display :0
14/11/2019 17:19:34 rootwin: 0x25f reswin: 0x1800001 dpy: 0x9c1bcc40
14/11/2019 17:19:34 
14/11/2019 17:19:34 ------------------ USEFUL INFORMATION ------------------
14/11/2019 17:19:34 
14/11/2019 17:19:34 Wireframing: -wireframe mode is in effect for window moves.
14/11/2019 17:19:34   If this yields undesired behavior (poor response, painting
14/11/2019 17:19:34   errors, etc) it may be disabled:
14/11/2019 17:19:34    - use '-nowf' to disable wireframing completely.
14/11/2019 17:19:34    - use '-nowcr' to disable the Copy Rectangle after the
14/11/2019 17:19:34      moved window is released in the new position.
14/11/2019 17:19:34   Also see the -help entry for tuning parameters.
14/11/2019 17:19:34   You can press 3 Alt_L's (Left "Alt" key) in a row to 
14/11/2019 17:19:34   repaint the screen, also see the -fixscreen option for
14/11/2019 17:19:34   periodic repaints.
14/11/2019 17:19:34 GrabServer control via XTEST.
14/11/2019 17:19:34 
14/11/2019 17:19:34 Scroll Detection: -scrollcopyrect mode is in effect to
14/11/2019 17:19:34   use RECORD extension to try to detect scrolling windows
14/11/2019 17:19:34   (induced by either user keystroke or mouse input).
14/11/2019 17:19:34   If this yields undesired behavior (poor response, painting
14/11/2019 17:19:34   errors, etc) it may be disabled via: '-noscr'
14/11/2019 17:19:34   Also see the -help entry for tuning parameters.
14/11/2019 17:19:34   You can press 3 Alt_L's (Left "Alt" key) in a row to 
14/11/2019 17:19:34   repaint the screen, also see the -fixscreen option for
14/11/2019 17:19:34   periodic repaints.
14/11/2019 17:19:34 
14/11/2019 17:19:34 XKEYBOARD: number of keysyms per keycode 7 is greater
14/11/2019 17:19:34   than 4 and 51 keysyms are mapped above 4.
14/11/2019 17:19:34   Automatically switching to -xkb mode.
14/11/2019 17:19:34   If this makes the key mapping worse you can
14/11/2019 17:19:34   disable it with the "-noxkb" option.
14/11/2019 17:19:34   Also, remember "-remap DEAD" for accenting characters.
14/11/2019 17:19:34 
14/11/2019 17:19:34 X FBPM extension not supported.
14/11/2019 17:19:34 X display is capable of DPMS.
14/11/2019 17:19:34 --------------------------------------------------------
14/11/2019 17:19:34 
14/11/2019 17:19:34 Default visual ID: 0x21
14/11/2019 17:19:34 Read initial data from X display into framebuffer.
14/11/2019 17:19:34 initialize_screen: fb_depth/fb_bpp/fb_Bpl 24/32/5120
14/11/2019 17:19:34 
14/11/2019 17:19:34 X display :0 is 32bpp depth=24 true color
14/11/2019 17:19:34 
14/11/2019 17:19:34 Autoprobing TCP port 
14/11/2019 17:19:34 Autoprobing selected TCP port 5900
14/11/2019 17:19:34 Autoprobing TCP6 port 
14/11/2019 17:19:34 Autoprobing selected TCP6 port 5900
14/11/2019 17:19:34 listen6: bind: Address already in use
14/11/2019 17:19:34 Not listening on IPv6 interface.
14/11/2019 17:19:34 
14/11/2019 17:19:34 Xinerama is present and active (e.g. multi-head).
14/11/2019 17:19:34 Xinerama: number of sub-screens: 1
14/11/2019 17:19:34 Xinerama: no blackouts needed (only one sub-screen)
14/11/2019 17:19:34 
14/11/2019 17:19:34 fb read rate: 636 MB/sec
14/11/2019 17:19:34 fast read: reset -wait  ms to: 10
14/11/2019 17:19:34 fast read: reset -defer ms to: 10
14/11/2019 17:19:34 The X server says there are 10 mouse buttons.
14/11/2019 17:19:34 screen setup finished.
14/11/2019 17:19:34 

The VNC desktop is:      test: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/
Пробуем подключиться VNC клиентом IP:5900 используя сгенерированный ранее пароль
Если все прошло нормально, в каталоге /home/user/.vnc/ создаем скрипт startvnc.sh следующего содержания:
#!/bin/sh
x11vnc -rfbauth ~/.vnc/x11vnc.pass -noxdamage -shared -dontdisconnect -many -noxfixes -bg
делаем его исполняемым
chmod +x ~/.vnc/startvnc.sh
Добавляем его в автозапуск для пользователя:
echo '/home/user/.vnc/startvnc.sh' >> ~/.config/lxsession/Lubuntu/autostart
После перезагрузки убеждаемся, что все работает, например используя Remmina:
P.S.
В дальнейшем планирую развить идею для подключения к RDP сеансам Linux сервера

2 комментария:

  1. А каким пакетом создаются эти RDP-сеансы на Linux-сервере? Передаёт ли он удалённо звук? Через клиент Remmina у меня звук не передавался при подключении к машине с Windows 10!

    ОтветитьУдалить
    Ответы
    1. У меня там была пара постов, о том, как настроить Linux RDP сервер на Debian 8/9(Пора пробовать 10). Для саппорта актуально иметь возможность подключиться в сеанс пользователя. Передавать медиаконтент через RDP по моему это мовентон: надо помнить, что на сервере работают десятки пользователей и если каждый запустит что то этакое то никто не сможет работать. Так что RDP сервер - это всетаки больше для оффисных и бухгалтерских приложений.

      Удалить