我想出了一些不完整的東西,但是現在我已經將.Xauthority重新定位到了〜/ tmp/.Xauthority,這實際上是一個很大的進步。 (Ubuntu服務器是目標OS)
所有的設置保持不變,只有一個文件需要創建的〜/ .ssh這是基於SSH -X服務器名的連接加載/ RC:
if read proto cookie && [ -n "$DISPLAY" ]; then
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
# X11UseLocalhost=yes
echo add unix:`echo $DISPLAY |
cut -c11-` $proto $cookie
else
# X11UseLocalhost=no
echo add $DISPLAY $proto $cookie
fi | xauth -q -f ~/tmp/.Xauthority -
fi
這啓動xauth並在您想要的位置創建文件,還會在.Xauthority文件中添加/創建條目以進行正確的身份驗證。
現在您需要修改〜。/ profile,因爲shell已加載,因此需要知道 .Xauthority文件的位置。因此,我們添加一行在最高層:
export XAUTHORITY=~/tmp/.Xauthority
這使我通過ssh -X服務器名稱連接到外殼並啓動任何應用X。讓我們嘗試通過啓動xeyes或xclock。
很酷,但還有另一個問題出現在我面前,但我現在沒有解決方案。如果您嘗試直接從遠程啓動X應用程序,如:
[email protected]:~$ ssh -X servername xeyes
X11 connection rejected because of wrong authentication.
X11 connection rejected because of wrong authentication.
X11 connection rejected because of wrong authentication.
X11 connection rejected because of wrong authentication.
Error: Can't open display: localhost:11.0
這是一個有趣的錯誤,因爲如果你google一下有很多答案,但現在的情況本身導致了假設:當bash被加載並且被排除在外時,情況有所不同。我唯一假設的是設置XAUTHORITY變量的.profile中的行,但是如何在不加載shell的情況下設置它。如果我有一個擁有默認位置(〜/ .Xauthority)中的.Xauthority文件的用戶,它爲什麼會起作用?