概述
我的目标是在 Ubuntu 16.04 LTS(带有桌面环境)上设置对使用 virt-manager 构建的 Debian 9.5 VM guest 虚拟机的 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 设置错误对我来说似乎很可疑,但我对这些东西了解不够,无法理解它。 (也许其他人可以?)
文件列表和调试
系统
<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
x启动
<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.
答案1
终于弄清楚了足以解决任何好奇的人的这种情况。
- 我的其他虚拟机设置在具有 sudo 权限的用户名下运行,而该用户不在 sudoers 列表中。
- 我尝试在 win10 virutalbox 设置上使用 deb9.4 来宾进行此操作,但遇到了同样的问题。
- 我更改了服务脚本权限,以便非 sudo 用户可以执行它,并且一切都开始工作——状态输出中的那些 gnome 设置错误仍然保留在我新的工作设置中。
简而言之,除了服务脚本权限问题之外,我对此不太了解。我认为,一些来自某人的额外意见将有助于澄清总体情况。