Debian

vncserver 空白顯示 – debian 9 guest VM w/ubuntu 16 host

  • August 17, 2018

概述

我的目標是在 Ubuntu 16.04 LTS(帶有桌面環境)上設置對使用 virt-manager 建構的 Debian 9.5 VM 來賓的 VNC 訪問。

我已將 /etc/vnc/xstartup 配置為使用 gnome-session(詳細資訊如下),並設置了在 /lib/systemd/system/{service-name}.service 中定義的 systemd 服務,它利用 /usr 中的腳本/local/bin/{service-script} 直接呼叫 /usr/bin/vncserver 執行停止和啟動操作。

目前的行為是當我從 LAN 上的另一台設備登錄 VNC 伺服器實例時出現一個空白螢幕,我想了解為什麼此配置不起作用以及更多關於 Ubuntu/Debian 桌面環境的資訊包層次結構。

夫妻注意事項:

  • 這個確切的配置使用執行虛擬框的 Windows 主機工作。
  • 這裡的所有設置都是我在網上找到的適用於我的 Windows 主機的東西(有效),所以請指出我可能不完全理解的多餘或無用的配置
  • 有問題的 {user} 不在 sudoers 列表中,但它是圖形安裝期間創建的第一個使用者
  • 狀態輸出中的 gnome-settings 錯誤對我來說似乎很可疑,但我對這些東西知之甚少,無法理解它。(也許其他人可以?)

文件列表和調試

系統

<user>@VPS:~$ ls -l /lib/systemd/system/<srvc-name>.service
-rw-r--r-- 1 root root 268 Aug 14 08:46 /lib/systemd/system/<srvc-name>.service

[Unit]
Description=Manage VNC Server

[Service]
Type=forking
ExecStart=/usr/local/bin/<srvc-script> start
ExecStop=/usr/local/bin/<srvc-script> stop
ExecReload=/usr/local/bin/<srvc-script> restart
User=<user>

[Install]
WantedBy=multi-user.target

服務腳本

<user>@VPS:~$ ls -l /usr/local/bin/<srvc-script>
-rwxr-xr-x 1 root staff 297 Aug 14 09:01 /usr/local/bin/<srvc-script>

#!/bin/bash

PATH="$PATH:/usr/bin/"
DISPLAY="2"
DEPTH="24"
GEOMETRY="1280x1024"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost no"

case "$1" in
start)
/usr/bin/vncserver ${OPTIONS}
;;

stop)
/usr/bin/vncserver -kill :${DISPLAY}
;;

restart)
$0 stop
$0 start
;;
esac
exit 0

啟動

<user>@VPS:~$ ls -l /etc/vnc/xstartup
-rwxr-xr-x 1 root root 155 Aug 14 13:52 /etc/vnc/xstartup

#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

xrdb $HOME/.Xresources
xsetroot -solid grey

export XKL_XMODMAP_DISABLE=1
gnome-session &

sudo 服務 {srvc-name} 狀態

● <srvc-name>.service - Manage VNC Server
  Loaded: loaded (/lib/systemd/system/<srvc-name>.service; enabled; vendor preset: enabled)
  Active: active (running) since Tue 2018-08-14 14:01:22 PDT; 1min 9s ago
 Process: 419 ExecStart=/usr/local/bin/<srvc-script> start (code=exited, status=0/SUCCESS)
   Tasks: 151 (limit: 4915)
  CGroup: /system.slice/<srvc-name>.service
          ├─487 /usr/bin/Xtigervnc :2 -desktop VPS:2 (<user>) -auth /home/<user>/.Xauthority -geometry 1280x1024 -depth 24 -rfbwait 30000 -rfbauth /home/<user>/.vnc/passwd -rfbport 5902 -pn -SecurityTypes VncAuth,TLSVnc
          ├─498 /usr/bin/perl /usr/bin/vncserver -depth 24 -geometry 1280x1024 :2 -localhost no
          ├─499 /bin/sh /etc/X11/Xvnc-session
          ├─501 vncconfig -iconic
          ├─502 /usr/lib/gnome-session/gnome-session-binary
          ├─540 dbus-launch --autolaunch 5e4be6148690420bb12518bb1b2bf070 --binary-syntax --close-stderr
          ├─554 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
          ├─612 /usr/bin/dbus-launch --exit-with-session --sh-syntax
          ├─615 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
          ├─658 /usr/bin/ssh-agent x-session-manager
          ├─674 /usr/lib/at-spi2-core/at-spi-bus-launcher
          ├─679 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
          ├─681 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
          ├─689 /usr/lib/gvfs/gvfsd
          ├─694 /usr/lib/gvfs/gvfsd-fuse /home/<user>/.gvfs -f -o big_writes
          ├─718 /usr/bin/gnome-keyring-daemon --start --components=secrets
          ├─736 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
          ├─757 /usr/bin/pulseaudio --start --log-target=syslog
          ├─780 /usr/lib/gnome-settings-daemon/gsd-printer
          ├─793 /usr/lib/evolution/evolution-alarm-notify
          ├─798 /usr/lib/tracker/tracker-store
          ├─799 /usr/lib/tracker/tracker-miner-user-guides
          ├─800 /usr/lib/tracker/tracker-miner-apps
          ├─802 /usr/lib/tracker/tracker-miner-fs
          ├─803 /usr/lib/tracker/tracker-extract
          ├─830 /usr/lib/evolution/evolution-source-registry
          ├─836 /usr/lib/gnome-online-accounts/goa-daemon
          ├─845 /usr/lib/telepathy/mission-control-5
          ├─846 /usr/lib/gnome-online-accounts/goa-identity-service
          ├─855 /usr/lib/evolution/evolution-calendar-factory
          ├─867 /usr/lib/evolution/evolution-calendar-factory-subprocess --factory contacts --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx855x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/855/2
          ├─869 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
          ├─886 /usr/lib/dconf/dconf-service
          ├─891 /usr/lib/evolution/evolution-addressbook-factory
          ├─892 /usr/lib/evolution/evolution-calendar-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx855x3 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/855/3
          ├─917 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
          ├─923 /usr/lib/evolution/evolution-addressbook-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.AddressBookx891x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/AddressBook/891/2
          ├─932 /usr/lib/gvfs/gvfs-afc-volume-monitor
          ├─944 /usr/lib/gvfs/gvfs-goa-volume-monitor
          └─949 /usr/lib/gvfs/gvfs-mtp-volume-monitor

Aug 14 14:01:21 VPS pulseaudio[776]: [pulseaudio] pid.c: Daemon already running.
Aug 14 14:01:21 VPS gnome-settings-[736]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
Aug 14 14:01:21 VPS gnome-settings-[736]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
Aug 14 14:01:21 VPS gnome-settings-[736]: Failed to StopUnit service: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
Aug 14 14:01:21 VPS gnome-settings-[736]: g_task_return_error: assertion 'error != NULL' failed
Aug 14 14:01:21 VPS gnome-session-binary[502]: Entering running state
Aug 14 14:01:21 VPS goa-daemon[836]: goa-daemon version 3.22.5 starting
Aug 14 14:01:22 VPS org.gtk.vfs.AfcVolumeMonitor[615]: Volume monitor alive
Aug 14 14:01:22 VPS systemd[1]: Started Manage VNC Server.
Aug 14 14:01:45 VPS pulseaudio[757]: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

終於想出足以解決任何好奇的人的這種情況。

  • 我的其他 VM 設置在具有 sudo 權限的使用者名下執行,而對於這個使用者,該使用者不在 sudoers 列表中。
  • 我試圖在 win10 virutalbox 設置上與 deb9.4 來賓一起使用,但遇到了同樣的問題。
  • 我更改了服務腳本權限,以便非 sudo 使用者可以執行它並且一切都開始工作 - 狀態輸出中的那些 gnome-settings 錯誤保留在我新工作的設置中。

簡而言之,除了服務腳本權限問題之外,我對此並不太了解。一些額外的輸入將有助於澄清我認為的整體情況。

引用自:https://unix.stackexchange.com/questions/462619