我有两个 raspi,并使用 SSH 和 X11 转发从一个连接到另一个ssh pi@[pi's IP] -X -v
。使用 X11 转发显示远程 GUI 对于许多应用程序来说效果很好。然而,对于一个应用程序来说它不起作用。这是演示应用程序 ADI TOF SDK。当我在“SSH -X”会话中启动此操作时,出现错误(在某些初始化步骤已经通过之后):
X11 connection rejected because of wrong authentication.
Gtk-WARNING **: 13:11:31.083: cannot open display: localhost:10.0
pi@aditofpi:~/Desktop $ ./aditof-demo.sh
I0604 13:11:28.104044 28301 device_enumerator_raspberry.cpp:16] Looking for devices on the target
I0604 13:11:28.105119 28301 device_enumerator_raspberry.cpp:49] Looking at: /dev/video0 for an eligible TOF camera
I0604 13:11:28.106060 28301 system_impl.cpp:31] System initialized
I0604 13:11:28.106182 28301 camera_96tof1.cpp:47] Initializing camera
I0604 13:11:28.106228 28301 local_device.cpp:118] Opening device
I0604 13:11:28.309844 28301 calibration.cpp:230] EEPROM calibration data size 65044 bytes
I0604 13:11:31.062580 28301 camera_96tof1.cpp:64] Camera initialized
I0604 13:11:31.069535 28301 local_device.cpp:213] Starting device
debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384
debug1: client_request_x11: request from ::1 52008
debug1: channel 1: new [x11]
debug1: confirm x11
X11 connection rejected because of wrong authentication.
debug1: channel 1: free: x11, nchannels 2
Unable to init server: Could not connect: Connection refused
(aditof-demo 1.2.0:28301): Gtk-WARNING **: 13:11:31.083: cannot open display: localhost:10.0
这显然不是一般的 X11 转发问题,因为它适用于其他应用程序。例如用 xclock 和 geany 进行测试。这是否与 aditof-demo 应用程序具有以下事实有关:几个 GUI 窗口?当我在本地启动应用程序时,我可以看到它们。 X11 转发可以处理这个问题吗(一个应用程序有多个不同的视窗)?我还尝试使用 -Y 而不是 -X 启动受信任的 ssh 会话,结果相同。我在两个系统上的 ssh_config 都包含以下块,这看起来没问题吗?
Host *
# ForwardAgent no
ForwardX11 yes
ForwardX11Trusted yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
知道为什么 X11 转发不仅适用于此特定应用程序,而且适用于其他应用程序吗?
更新:我尝试以 pi 用户和 sudo 用户身份启动 aditof 应用程序。两者都不起作用,并且输出是相同的。然而,当我用 geany 测试时,实际上存在差异。它以用户 pi 的身份工作,但不能以 sudo 的身份工作。与 sudo 一样,geany 也会失败,并出现与 aditif 应用程序相同的错误。嗯,这很奇怪。
pi@aditofpi:~/Desktop $ geany
debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384
debug1: client_request_x11: request from ::1 56062
debug1: channel 1: new [x11]
debug1: confirm x11
debug1: channel 1: FORCE input drain
debug1: channel 1: free: x11, nchannels 2
pi@aditofpi:~/Desktop $ sudo geany
debug1: client_input_channel_open: ctype x11 rchan 3 win 65536 max 16384
debug1: client_request_x11: request from ::1 56066
debug1: channel 1: new [x11]
debug1: confirm x11
X11 connection rejected because of wrong authentication.
debug1: channel 1: free: x11, nchannels 2
Unable to init server: Could not connect: Connection refused
Geany: cannot open display
答案1
我刚刚发现这实际上是不是与如上所述的特定应用程序相关,但当我运行程序时,这是所有应用程序的普遍问题sudo
!我总是在会话X11 connection rejected because of wrong authentication.
中启动某些内容时出现此错误。当与 user 启动相同的应用程序时,它总是工作正常。我一开始没有看到这一点的原因是,aditof 应用程序的 隐藏在 .sh 文件中。我以用户 pi 的身份启动此操作,但 .sh 文件内有以下内容:ssh -X
sudo
pi
sudo
#!/bin/sh
cd /home/pi/aditof_sdk/build/examples/aditof-demo
sudo ./aditof-demo
更改为后:
#!/bin/sh
cd /home/pi/aditof_sdk/build/examples/aditof-demo
./aditof-demo
并这样做:
pi@raspberrypi:~ $ ssh pi@aditofpi'sID -X
pi@aditofpi'sID's password:
Linux aditofpi 4.19.86-v7l+ #1 SMP Tue Dec 3 17:21:04 EET 2019 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jun 9 15:09:15 2020 from aditofpi'sID
pi@aditofpi:~ $ ~/Desktop/aditof-demo.sh
应用程序编辑开始! :) 中级 是啊!与 xclock 或 geany 等其他应用程序的行为相同。以用户 pi 身份工作,以 sudo 身份启动时不起作用并失败X11 connection rejected because of wrong authentication.
。但这是另一个话题了。