Vnc: различия между версиями
Перейти к навигации
Перейти к поиску
Vovan (обсуждение | вклад) (→Виртуальный дисплей через VNC) |
Vovan (обсуждение | вклад) (→Виртуальный дисплей через VNC) |
||
Строка 143: | Строка 143: | ||
=Виртуальный дисплей через VNC= | =Виртуальный дисплей через VNC= | ||
+ | ==один дополнительный дисплей== | ||
<pre> | <pre> | ||
cat << 'EOF' > ./q.sh | cat << 'EOF' > ./q.sh | ||
Строка 176: | Строка 177: | ||
#docker run --name display1 -p 8081:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5900 dougw/novnc | #docker run --name display1 -p 8081:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5900 dougw/novnc | ||
+ | |||
+ | EOF | ||
+ | </pre> | ||
+ | |||
+ | ==два дополнительных дисплея== | ||
+ | <pre> | ||
+ | cat << 'EOF' > ./q.sh | ||
+ | #!/bin/bash | ||
+ | |||
+ | # find an unused output | ||
+ | find -L /sys/class/drm -maxdepth 1 -type d -name 'card0-*' -exec sh -c 'if [ $(cat $0/status) = "disconnected" ]; then echo $0; fi' {} \;|cut -c22-|sort | ||
+ | #on my system DP-1 is available | ||
+ | OUTPUT=HDMI-A-2 | ||
+ | DIR=/sys/kernel/debug/dri/0/$OUTPUT | ||
+ | |||
+ | # override EDID (pretend to be a 1080P monitor with lots of resolution options) | ||
+ | EDID_BASE64=AP///////wAebdVZ+KEJAAQXAQNoNR546jMxpFdRoCYQUFSna4CzAIGAlQBxT6nAgQCBwJBAAjqAGHE4LUBYLEUACSUhAAAeAAAA/QA4Sx5TDwAKICAgICAgAAAA/AAyNEVOMzMKICAgICAgAAAA/wAzMDRORFBISksyODgKAJ8= | ||
+ | sudo bash -c "base64 -d <<<$EDID_BASE64 > $DIR/edid_override" | ||
+ | |||
+ | # force output on | ||
+ | sudo sh -c "echo on > $DIR/force" | ||
+ | |||
+ | # add an additional resolution to the dummy display (optional) | ||
+ | # check the xrandr output name, it may be different than the kernel name | ||
+ | xrandr|grep ' connected' | ||
+ | OUTPUT=HDMI-A-2 | ||
+ | RES="1920 1080" | ||
+ | MODELINE=$(cvt $RES|awk '/Modeline/{print substr($0,10)}') | ||
+ | MODE="1920x1080_60" #$(sed 's/^"\([^"]\+\).*/\1/' <<<$MODELINE | awk -F '_' {'print $1'}) | ||
+ | sh -c "xrandr --newmode $MODELINE" | ||
+ | xrandr --addmode $OUTPUT $MODE | ||
+ | |||
+ | # Use the standard display configuration utility to configure the dummy display. | ||
+ | # Match the resolution of your device and position the display. | ||
+ | |||
+ | #second display | ||
+ | OUTPUT=VGA-1 | ||
+ | DIR=/sys/kernel/debug/dri/0/$OUTPUT | ||
+ | sudo bash -c "base64 -d <<<$EDID_BASE64 > $DIR/edid_override" | ||
+ | sudo sh -c "echo on > $DIR/force" | ||
+ | xrandr|grep ' connected' | ||
+ | RES="1920 1080" | ||
+ | MODELINE=$(cvt $RES|awk '/Modeline/{print substr($0,10)}') | ||
+ | MODE="1920x1080_60" #$(sed 's/^"\([^"]\+\).*/\1/' <<<$MODELINE | awk -F '_' {'print $1'}) | ||
+ | sh -c "xrandr --newmode $MODELINE" | ||
+ | xrandr --addmode $OUTPUT $MODE | ||
+ | |||
+ | x11vnc -auth /run/user/500/gdm/Xauthority -rfbauth /home/vslugin/.vnc/passwd -display :0 -clip 1440x900+0+180 -viewonly -rfbport 5900 -nonc -forever & | ||
+ | |||
+ | x11vnc -auth /run/user/500/gdm/Xauthority -rfbauth /home/vslugin/.vnc/passwd -display :0 -clip 1440x900+4000+180 -viewonly -rfbport 5901 -nonc -forever & | ||
+ | |||
+ | #docker run --name display1 -p 8081:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5900 dougw/novnc | ||
+ | |||
+ | #docker run --name display2 -p 8082:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5901 dougw/novnc | ||
EOF | EOF | ||
</pre> | </pre> |
Версия 18:35, 17 декабря 2022
Содержание
VNC-server ubuntu
проверено на Ubuntu 14.04.1 MATE i386
--Vovan (обсуждение) 16:15, 15 марта 2015 (UTC)
установка
sudo su apt install x11vnc
формирование файла с паролем
x11vnc -storepasswd
результат формирования пароля будет в файле
/root/.vnc/passwd
VNC-server alt starterkit gnome3
x11vnc -auth /run/user/500/gdm/Xauthority -rfbauth /root/.vnc/passwd -display :1 -ncache 1 -rfbport 5905
Полезное
Трансляция рабочего стола преподавателя
транслируем только левый дисплей в двухмониторной конфигурации
x11vnc -clip 1920x1080+0+0 -display :0 -viewonly -shared -rfbport 5900 -rfbauth .vnc/passwd
Как systemd сервис
Создать файл, например:
/etc/systemd/system/x11vnc.service
Со следующим содержимым:
[Unit] Description=x11vnc Requires=network-online.target After=network-online.target [Service] Restart=on-failure ExecStart=/usr/bin/x11vnc -dontdisconnect -display :0 -auth /var/run/lightdm/root/:0 -shared -forever -rfbport 5900 -rfbauth /root/.vnc/passwd User=root Group=root [Install] WantedBy=multi-user.target
далее выполнить:
systemctl daemon-reload systemctl enable x11vnc.service
проверить статус:
systemctl status x11vnc.service
проверить журнал:
journalctl -lf -u x11vnc.service
Примеры сервисов
cat /etc/systemd/system/x11vnc.service [Unit] Description=x11vnc Requires=network-online.target After=network-online.target [Service] Restart=on-failure ExecStart=/usr/bin/x11vnc -dontdisconnect -display :0 -viewonly -shared -auth /var/run/lightdm/root/:0 -forever -rfbport 5900 -rfbauth /root/.vnc/passwd User=root Group=root [Install] WantedBy=multi-user.target
cat /etc/systemd/system/x11vnc-5901.service [Unit] Description=x11vnc Requires=network-online.target After=network-online.target [Service] Restart=on-failure ExecStart=/usr/bin/x11vnc -dontdisconnect -display :0 -auth /var/run/lightdm/root/:0 -forever -rfbport 5901 -rfbauth /root/.vnc/passwd User=root Group=root [Install] WantedBy=multi-user.target
Полезные параметры
Параметр, который включает показ курсора на удалённом клиенте (актуально для клиента VNC Viewer под iPad)
-multiptr
Запустить контейнер с NoVNC для трансляции рабочего стола в браузер
cat /opt/start-vnc-proxy.sh
#!/bin/bash #teacher ro docker run --name teacher-ro --rm -p 8751:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5900 dougw/novnc #teacher rw docker run --name teacher-rw --rm -p 8750:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5901 dougw/novnc
cat /opt/stop-vnc-proxy.sh
#!/bin/bash docker stop teacher-ro teacher-rw
Виртуальный дисплей через VNC
один дополнительный дисплей
cat << 'EOF' > ./q.sh #!/bin/bash # find an unused output find -L /sys/class/drm -maxdepth 1 -type d -name 'card0-*' -exec sh -c 'if [ $(cat $0/status) = "disconnected" ]; then echo $0; fi' {} \;|cut -c22-|sort #on my system DP-1 is available OUTPUT=HDMI-A-2 DIR=/sys/kernel/debug/dri/0/$OUTPUT # override EDID (pretend to be a 1080P monitor with lots of resolution options) EDID_BASE64=AP///////wAebdVZ+KEJAAQXAQNoNR546jMxpFdRoCYQUFSna4CzAIGAlQBxT6nAgQCBwJBAAjqAGHE4LUBYLEUACSUhAAAeAAAA/QA4Sx5TDwAKICAgICAgAAAA/AAyNEVOMzMKICAgICAgAAAA/wAzMDRORFBISksyODgKAJ8= sudo bash -c "base64 -d <<<$EDID_BASE64 > $DIR/edid_override" # force output on sudo sh -c "echo on > $DIR/force" # add an additional resolution to the dummy display (optional) # check the xrandr output name, it may be different than the kernel name xrandr|grep ' connected' OUTPUT=HDMI-A-2 RES="1920 1080" MODELINE=$(cvt $RES|awk '/Modeline/{print substr($0,10)}') MODE="1920x1080_60" #$(sed 's/^"\([^"]\+\).*/\1/' <<<$MODELINE | awk -F '_' {'print $1'}) sh -c "xrandr --newmode $MODELINE" xrandr --addmode $OUTPUT $MODE # Use the standard display configuration utility to configure the dummy display. # Match the resolution of your device and position the display. x11vnc -auth /run/user/500/gdm/Xauthority -rfbauth /home/vslugin/.vnc/passwd -display :0 -clip 1440x900+0+180 -viewonly -rfbport 5900 -nonc #docker run --name display1 -p 8081:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5900 dougw/novnc EOF
два дополнительных дисплея
cat << 'EOF' > ./q.sh #!/bin/bash # find an unused output find -L /sys/class/drm -maxdepth 1 -type d -name 'card0-*' -exec sh -c 'if [ $(cat $0/status) = "disconnected" ]; then echo $0; fi' {} \;|cut -c22-|sort #on my system DP-1 is available OUTPUT=HDMI-A-2 DIR=/sys/kernel/debug/dri/0/$OUTPUT # override EDID (pretend to be a 1080P monitor with lots of resolution options) EDID_BASE64=AP///////wAebdVZ+KEJAAQXAQNoNR546jMxpFdRoCYQUFSna4CzAIGAlQBxT6nAgQCBwJBAAjqAGHE4LUBYLEUACSUhAAAeAAAA/QA4Sx5TDwAKICAgICAgAAAA/AAyNEVOMzMKICAgICAgAAAA/wAzMDRORFBISksyODgKAJ8= sudo bash -c "base64 -d <<<$EDID_BASE64 > $DIR/edid_override" # force output on sudo sh -c "echo on > $DIR/force" # add an additional resolution to the dummy display (optional) # check the xrandr output name, it may be different than the kernel name xrandr|grep ' connected' OUTPUT=HDMI-A-2 RES="1920 1080" MODELINE=$(cvt $RES|awk '/Modeline/{print substr($0,10)}') MODE="1920x1080_60" #$(sed 's/^"\([^"]\+\).*/\1/' <<<$MODELINE | awk -F '_' {'print $1'}) sh -c "xrandr --newmode $MODELINE" xrandr --addmode $OUTPUT $MODE # Use the standard display configuration utility to configure the dummy display. # Match the resolution of your device and position the display. #second display OUTPUT=VGA-1 DIR=/sys/kernel/debug/dri/0/$OUTPUT sudo bash -c "base64 -d <<<$EDID_BASE64 > $DIR/edid_override" sudo sh -c "echo on > $DIR/force" xrandr|grep ' connected' RES="1920 1080" MODELINE=$(cvt $RES|awk '/Modeline/{print substr($0,10)}') MODE="1920x1080_60" #$(sed 's/^"\([^"]\+\).*/\1/' <<<$MODELINE | awk -F '_' {'print $1'}) sh -c "xrandr --newmode $MODELINE" xrandr --addmode $OUTPUT $MODE x11vnc -auth /run/user/500/gdm/Xauthority -rfbauth /home/vslugin/.vnc/passwd -display :0 -clip 1440x900+0+180 -viewonly -rfbport 5900 -nonc -forever & x11vnc -auth /run/user/500/gdm/Xauthority -rfbauth /home/vslugin/.vnc/passwd -display :0 -clip 1440x900+4000+180 -viewonly -rfbport 5901 -nonc -forever & #docker run --name display1 -p 8081:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5900 dougw/novnc #docker run --name display2 -p 8082:8081 -d -e REMOTE_HOST=172.17.0.1 -e REMOTE_PORT=5901 dougw/novnc EOF