登入時,ssh -Y remotehost
我收到以下錯誤訊息:
/usr/bin/xauth: /home/hlovdal/.Xauthority 不可寫,變更將被忽略
和xclock之類的無法啟動。儘管出現錯誤訊息,.Xauthority 檔案的權限沒有任何問題。
(hlovdal) remotehost:~>xclock
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:10.0
(hlovdal) remotehost:~>ls -l /home/hlovdal/.Xauthority
-rw-------. 1 hlovdal hlovdal 70 Jul 25 23:30 /home/hlovdal/.Xauthority
(hlovdal) remotehost:~>
這裡可能是什麼原因?
(這是在我的兩台筆記型電腦之間進行的,我之前已經來回噓了數百次。)
更新:
在進一步調試時,xauth 再次抱怨它無法寫入 .Xauthority 這沒有意義,因為該文件可由我的用戶寫入,出於好奇,我運行 strace 來查看它嘗試執行的操作。
(hlovdal) remotehost:~>xauth list
xauth: /home/hlovdal/.Xauthority not writable, changes will be ignored
(hlovdal) remotehost:~>strace -oout -f -s9000 xauth list
xauth: error in locking authority file /home/hlovdal/.Xauthority
(hlovdal) remotehost:~>tail out
16634 brk(0xf03000) = 0xf03000
16634 brk(0) = 0xf03000
16634 rt_sigaction(SIGINT, {0x4050d0, [INT], SA_RESTORER|SA_RESTART, 0x3957035350}, {SIG_DFL, [], 0}, 8) = 0
16634 rt_sigaction(SIGTERM, {0x4050d0, [TERM], SA_RESTORER|SA_RESTART, 0x3957035350}, {SIG_DFL, [], 0}, 8) = 0
16634 rt_sigaction(SIGHUP, {0x4050d0, [HUP], SA_RESTORER|SA_RESTART, 0x3957035350}, {SIG_DFL, [], 0}, 8) = 0
16634 rt_sigaction(SIGPIPE, {0x4050d0, [PIPE], SA_RESTORER|SA_RESTART, 0x3957035350}, {SIG_DFL, [], 0}, 8) = 0
16634 stat("/home/hlovdal/.Xauthority-c", {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
16634 open("/home/hlovdal/.Xauthority-c", O_WRONLY|O_CREAT|O_EXCL, 0600) = -1 EEXIST (File exists)
16634 write(2, "xauth: error in locking authority file /home/hlovdal/.Xauthority\n", 66) = 66
16634 exit_group(1) = ?
(hlovdal) remotehost:~>ls -l .Xauthority*
-rw-------. 1 hlovdal hlovdal 70 Jul 25 23:30 .Xauthority
-rw-------. 2 hlovdal hlovdal 0 Jul 26 01:26 .Xauthority-c
-rw-------. 2 hlovdal hlovdal 0 Jul 26 01:26 .Xauthority-l
(hlovdal) remotehost:~>
這更好地解釋了為什麼 xauth 失敗,因為它無法創建 .Xauthority-c。但是刪除這兩個可能過時的檔案並沒有幫助,它們會在下次 ssh 登入時重新建立。 Remotehost 中的 syslog 包含以下與 ssh 登入相關的內容。
sshd[17551]: Accepted publickey for hlovdal from x.x.x.x port 36545 ssh2
sshd[17552]: fatal: mm_request_receive: read: Connection reset by peer
sshd[17551]: pam_unix(sshd:session): session opened for user hlovdal by (uid=0)
這個mm_request_receive錯誤訊息以前從未出現過,所以我猜有進一步調試的線索。
答案1
在 Ubuntu 12.04 上同步我的主資料夾後,我遇到了同樣的問題。我使用以下命令解決了它:
rm ~/.Xaut*
然後我登出並重新登入。
/usr/bin/xauth: file /home/iranice/.Xauthority does not exist
之後,Linux.Xauthority
自動建立檔案。我登出並重新登錄,一切正常。
答案2
對我來說,我遇到了這個錯誤:
/usr/bin/xauth: error in locking authority file /home/toto/.Xauthority
因為我的 /home 分區已滿。
釋放該分區上的一些空間解決了這個問題。
strace 指令:strace -oout -f -s9000 xauth list
對於辨識問題很有用。
答案3
這似乎是一個已知問題,報告於Redhat 的 bugzilla,所以我將“關閉”這個問題並繼續向該錯誤報告報告。
答案4
對我來說,問題是權限問題。即使您刪除了該文件.Xauthority
,它也會重新建立並且不可寫入。所以我改變了所有者並且它起作用了:
sudo chown user:user .Xauthority
可能該文件是預設為 root 創建的。