当我尝试通过 VNC 查看 ubuntu 机器时,我得到一个带有 3 个复选框的灰色屏幕。我尝试了一些我在网上读到的建议,但其中一个没有帮助。一个仍然给我一个带有 3 个复选框的灰色屏幕,一个给我一个没有三个复选框的灰色屏幕,一个给我一个网格!这是关于如何修改 vnc 的 xstartup 文件的各种建议。下面进一步阐述。
我有一台通过 USB 运行 Ubuntu 18.03.3 LTS 的电脑。它提供了两个选项,“试用 ubuntu”和“安装 ubuntu”,我选择了“试用 ubuntu”。
$lsb_release -a
我参加的节目Ubuntu 18.04.03 LTS
我看见本文并使用这些命令来安装 vnc 服务器
$ sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal gnome-core
$ sudo apt-get install vnc4server
这显示了我的 xstartup 文件
buntu@ubuntu:~/.vnc$ cat xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
ubuntu@ubuntu:~/.vnc$
我认为这是默认的。我得到了与提到的相同的错误
和
和
但那里的解决方案对我来说不起作用,我会解释的。
我得到一个带有 3 个复选框的灰色屏幕。
在这里,我启动了 vnc 服务器(我还加入了一些我使用过的其他命令,用于列出进程,因为每次我更改 xstartup 时,我都会查看服务器是否正在运行,然后将其终止并重新启动)。我检查了它是否正在运行以及在哪个端口上运行,即端口 5901。并且它没有被 ubuntu 默认使用的防火墙阻止。ufw,我看到ufw status
ufw 防火墙未启用,因此没有问题。vnc 服务器已启动。
ubuntu@ubuntu:~/.vnc$ ps
PID TTY TIME CMD
6065 pts/0 00:00:00 bash
15274 pts/0 00:00:00 ps
ubuntu@ubuntu:~/.vnc$ cat xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
ubuntu@ubuntu:~/.vnc$ vnc4server
New 'ubuntu:1 (ubuntu)' desktop is ubuntu:1
Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ubuntu:1.log
ubuntu@ubuntu:~/.vnc$ ps
PID TTY TIME CMD
6065 pts/0 00:00:00 bash
15287 pts/0 00:00:00 Xvnc4
15293 pts/0 00:00:00 vncconfig
15303 pts/0 00:00:00 ps
ubuntu@ubuntu:~/.vnc$ lsof | grep LISTEN
lsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing
Output information may be incomplete.
Xvnc4 15287 ubuntu 0u IPv4 295628 0t0 TCP *:x11-1 (LISTEN)
Xvnc4 15287 ubuntu 3u IPv6 295630 0t0 TCP *:5901 (LISTEN)
ubuntu@ubuntu:~/.vnc$ ufw status
ERROR: You need to be root to run this script
ubuntu@ubuntu:~/.vnc$ sudo ufw status
Status: inactive
ubuntu@ubuntu:~/.vnc$
我也运行ip add
命令来查看我的IP。
然后我转到另一台运行 Windows 的机器,输入 IP:5901 并输入正确的密码,密码被接受。
然后我看到一个灰色屏幕,上面有三个复选框:“接受来自观众的剪贴板”、“将剪贴板发送给观众”、“将主要选择发送给观众”
我根据第一个链接 vnc-grey-screen (172384) 进行了修改,但得到了相同的灰色屏幕,相同的三个复选框,即
ubuntu@ubuntu:~/.vnc$ echo https://askubuntu.com/questions/172384/vnc-grey-screen-and-start-on-boot-12-04
https://askubuntu.com/questions/172384/vnc-grey-screen-and-start-on-boot-12-04
ubuntu@ubuntu:~/.vnc$ cat xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
gnome-session --session=gnome-classic &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 1280x1024+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
ubuntu@ubuntu:~/.vnc$ ps
PID TTY TIME CMD
6065 pts/0 00:00:00 bash
15287 pts/0 00:00:00 Xvnc4
15293 pts/0 00:00:00 vncconfig
15572 pts/0 00:00:00 ps
ubuntu@ubuntu:~/.vnc$ killall Xvnc4
ubuntu@ubuntu:~/.vnc$ ps
PID TTY TIME CMD
6065 pts/0 00:00:00 bash
15575 pts/0 00:00:00 ps
ubuntu@ubuntu:~/.vnc$ vnc4server
New 'ubuntu:1 (ubuntu)' desktop is ubuntu:1
Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ubuntu:1.log
ubuntu@ubuntu:~/.vnc$
然后我尝试使用第二个 ubuntu 链接 (vncserver-grey-screen - 800302) 中的内容进行 xstartup
ubuntu@ubuntu:~/.vnc$ vi xstartup
ubuntu@ubuntu:~/.vnc$ echo https://askubuntu.com/questions/800302/vncserver-grey-screen-ubuntu-16-04-lts
https://askubuntu.com/questions/800302/vncserver-grey-screen-ubuntu-16-04-lts
ubuntu@ubuntu:~/.vnc$ cat xstartup
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
ubuntu@ubuntu:~/.vnc$ ps
PID TTY TIME CMD
6065 pts/0 00:00:00 bash
15710 pts/0 00:00:00 ps
ubuntu@ubuntu:~/.vnc$ vnc4server
New 'ubuntu:1 (ubuntu)' desktop is ubuntu:1
Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ubuntu:1.log
ubuntu@ubuntu:~/.vnc$
但这次我得到的是灰色屏幕,没有复选框
然后我尝试第三种解决方案
一个建议说确保 xstartup 文件的权限是 755,我的是,另一个建议取消注释以下两行:
unset SESSION MANAGER
exec /etc/X11/xinit/xinitrc
这样做(当然还要终止并启动 vnc 服务器) $killall Xvnc4<ENTER>
并 $vnc4server<ENTER>
当我尝试连接时,我得到了这个屏幕,它就像一个网格
添加
我听到有人建议尝试查看日志文件 /home/ubuntu/.vnc/ubuntu:1.log
ubuntu@ubuntu:~/.vnc$ cat ubuntu:1.log
Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc
Tue Feb 4 21:56:29 2020
vncext: VNC extension running!
vncext: Listening for VNC connections on port 5901
vncext: created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
Tue Feb 4 21:56:39 2020
Connections: accepted: 0.0.0.0::62323
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VncAuth(2)
Tue Feb 4 21:56:43 2020
VNCSConnST: Server default pixel format depth 16 (16bpp) little-endian rgb565
VNCSConnST: Client pixel format depth 6 (8bpp) rgb222
Tue Feb 4 21:56:44 2020
VNCSConnST: Client pixel format depth 16 (16bpp) little-endian rgb565
ubuntu@ubuntu:~/.vnc$
我也发现了这个建议https://stackoverflow.com/questions/51415427/whats-wrong-with-my-vncserver-setting 这会产生一个没有复选框的灰色屏幕。
我听到有人建议尝试这个 xstartup 文件,特别是第 14-17 行可能会有帮助https://www.linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-18-04/
所以我使用了整个 xstartup 文件,因为我对 xstartup 文件做了相当多的修改。
我收到一个灰色屏幕,没有复选框,日志显示
ubuntu@ubuntu:~/.vnc$ cat ubuntu\:1.log
Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc
Tue Feb 4 23:10:06 2020
vncext: VNC extension running!
vncext: Listening for VNC connections on port 5901
vncext: created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
/home/ubuntu/.vnc/xstartup: 15: /home/ubuntu/.vnc/xstartup: gnome-settings-daemon: not found
** (gnome-panel:16733): WARNING **: 23:10:09.203: Failed to request name: the name already has an owner
xkbcommon: ERROR: xkb_x11_keymap_new_from_device: illegal device ID: -1
xkbcommon: ERROR: xkb_x11_state_new_from_device: illegal device ID: -1metacity-Message: 23:10:09.279: could not find XKB extension.
(metacity:16735): metacity-WARNING **: 23:10:09.285: Failed to create MetaCompositorXRender: Missing composite extension required for compositing
# Failed to parse arguments: Unknown option --login
Tue Feb 4 23:10:17 2020
Connections: accepted: 0.0.0.0::63052
SConnection: Client needs protocol version 3.8
SConnection: Client requests security type VncAuth(2)
Tue Feb 4 23:10:20 2020
VNCSConnST: Server default pixel format depth 16 (16bpp) little-endian rgb565
VNCSConnST: Client pixel format depth 6 (8bpp) rgb222
VNCSConnST: Client pixel format depth 16 (16bpp) little-endian rgb565
Tue Feb 4 23:10:25 2020
Connections: closed: 0.0.0.0::63052 (Clean disconnection)
SMsgWriter: framebuffer updates 3
SMsgWriter: raw rects 1, bytes 16396
SMsgWriter: ZRLE rects 3, bytes 304
SMsgWriter: raw bytes equivalent 2375888, compression ratio 142.268743
ubuntu@ubuntu:~/.vnc$
答案1
我按照指示https://itectec.com/ubuntu/ubuntu-ubuntu-18-04-vnc-grey-screen/ 它解决了我的 vnc 灰屏问题。
sudo apt install gnome-session-flashback
然后改变~/.vnc/xstartup
#!/bin/sh
autocutsel -fork
xrdb $HOME/.Xresources
xsetroot -solid grey
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:Unity"
export XDG_MENU_PREFIX="gnome-flashback-"
unset DBUS_SESSION_BUS_ADDRESS
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check --debug &