問題:GDM/KDE 在 CentOS 8 中預設使用 DISPLAY :1 而不是 DISPLAY :0,我希望它像在 CentOS 7 中一樣使用 DISPLAY:0。現在根本無法透過VNC 進入登入畫面)。
舊/工作版本
- 作業系統7
- KDE SC 版本 4.14.8
- GDM 版本 3.28.2
當 ssh 進入舊機器運行 x11vnc 時,我們可以看到 :0 是 DISPLAY
$ w -us
USER TTY FROM IDLE WHAT
user :0 :0 ?xdm? /bin/sh /usr/bin/startkde
損壞/新版本
- CentOS Stream 8
- KDE 等離子版本:5.18.4
- GDM 版本 40.0
當 ssh'ing 到新機器運行 x11vnc 時,我們可以看到 :1 是 DISPLAY
$ w -us
USER TTY FROM IDLE WHAT
user :1 :1 ?xdm? /usr/libexec/gdm-x-session --register-session --run-script /usr/bin/startplasma-x11
user pts/0 :1 46:05 kded5
因此,現在要在 CentOS 8 上的登入會話中啟動 x11vnc,我需要運行x11vnc -display :1
,這沒什麼大不了的,只是有點煩人並且會影響一些腳本。更大的問題是我現在無法透過 VNC 進入登入畫面。使用 off 變體ssh -X
x11vnc -display :1
、以 root 身份運行等等。
兩者都有完全相同的 ssh 配置(X11 轉發等)。
編輯:
嘗試透過 VNC 進入登入畫面時發生錯誤:
~> ssh user@centos8
$ echo $DISPLAY
$ x11vnc # this works on CentOS 7 w/ and w/o X11 forwarding
...
10/06/2021 16:28:55 *** XOpenDisplay failed. No -display or DISPLAY.
Invalid MIT-MAGIC-COOKIE-1 key10/06/2021 16:28:59 XOpenDisplay(":0") failed.
10/06/2021 16:28:59 Trying again with XAUTHLOCALHOSTNAME=localhost ...
Invalid MIT-MAGIC-COOKIE-1 key10/06/2021 16:28:59 XOpenDisplay(":0") failed.
10/06/2021 16:28:59 Trying again with unset XAUTHLOCALHOSTNAME ...
Invalid MIT-MAGIC-COOKIE-1 key10/06/2021 16:28:59
...
10/06/2021 16:28:59 ***************************************
10/06/2021 16:28:59 *** XOpenDisplay failed (:0)
...
$ x11vnc -display :1
10/06/2021 16:30:16 *** XOpenDisplay failed (:1)
$ exit
~> ssh -X user@centos8
$ echo $DISPLAY
localhost:10.0
$ x11vnc
...
10/06/2021 16:24:16 WARNING: DISPLAY starts with localhost: 'localhost:10.0'
10/06/2021 16:24:16 WARNING: Is this an SSH X11 port forwarding? You most
10/06/2021 16:24:16 WARNING: likely don't want x11vnc to use that DISPLAY.
10/06/2021 16:24:16 WARNING: You probably should supply something
10/06/2021 16:24:16 WARNING: like: -display :0 to access the physical
10/06/2021 16:24:16 WARNING: X display on the machine where x11vnc is running.
...
X11 MIT Shared Memory Attach failed:
Is your DISPLAY=localhost:10.0 on a remote machine?
Note: DISPLAY=localhost:N suggests a SSH X11 redir to a remote machine.
Suggestion, use: x11vnc -display :0 ... for local display :0
caught X11 error:
10/06/2021 16:24:17 deleted 53 tile_row polling images.
X Error of failed request: BadRequest (invalid request code or no such operation)
Major opcode of failed request: 130 (MIT-SHM)
Minor opcode of failed request: 1 (X_ShmAttach)
Serial number of failed request: 56
Current serial number in output stream: 111
$ x11vnc -display :1
...
10/06/2021 16:26:16 *** XOpenDisplay failed (:1)
...
以 root 身分執行類似錯誤
答案1
我從CentOS7 gdm-3.28.2-26.el7.x86_64.rpm 和pulseaudio-gdm-hooks-10.0-6.el7_9.x86_64.rpm 下載並使用以下命令在Rocky Linux 8 (8.4) Linux 上安裝(降級)這兩個軟體包: dnf 安裝 gdm-3.28.2-26.el7.x86_64.rpmpulseaudio-gdm-hooks-10.0-6.el7_9.x86_64.rpm
這個稍舊版本中的 gdm 使用“DISPLAY :0”,我可以使用 x11vnc 登入登入畫面。不確定 gdm 有哪些依賴項以及可能會發生哪些副作用。更新作業系統將重新安裝使用「DISPLAY :1」的 Rocky Linux 8 的較新 gdm 版本。
答案2
我也有同樣的問題,真的很煩。我的強力解決方案只是將 VNC 包裝在腳本中,嘗試顯示 :0 和 :1。 :0 始終是登入畫面,:1 始終是 gnome 會話。這樣,我就可以透過 VNC 進入工作站並登入。註銷也會殺死 X,因此 VNC 會話再次終止。
就像是,
(
while true; do
for displayNum in {0..1} ; do
if ! pgrep -f "x11vnc -repeat -display" > /dev/null; then
currentUserId=$(pgrep -x gnome-shell |
xargs --no-run-if-empty ps -ho uid |
awk '{print $1}')
x11vnc -repeat -display ":${displayNum}" -rfbport 5900 \
-shared -auth /run/user/${currentUserId}/gdm/Xauthority \
-forever
sleep 0.5
else
sleep 10
fi
done
done
) &