xauth 不创建 .Xauthority 文件

wkd*_*rty 47 linux ssh xauth

当我通过 ssh 进入无头 Linux Mint 17 系统时,它不会创建更新/创建 .Xauthority 文件。

此外,当我运行时,xauth我得到了答复:

marty@N40L ~ $ xauth
xauth:  file /home/marty/.Xauthority does not exist
Using authority file /home/marty/.Xauthority
xauth>exit
marty@N40L ~ $ xauth
xauth:  file /home/marty/.Xauthority does not exist
Using authority file /home/marty/.Xauthority
xauth>
Run Code Online (Sandbox Code Playgroud)

它不会创建文件。

编辑:

当我连接监视器,然后在本地登录时,会创建该文件,但是当我尝试添加一个条目时(因为我的 SSH 不适合我):

marty@N40L ~ $ xauth list
N40L/unix:0  MIT-MAGIC-COOKIE-1  34eee3b15cdb281021502d40dfba1cf2
localhost.localdomain/unix:0  MIT-MAGIC-COOKIE-1  34eee3b15cdb281021502d40dfba1cf2
marty@N40L ~ $ ls -d .X*
-rw------- 1 marty marty 115 Sep  3 12:03 .Xauthority
marty@N40L ~ $ xauth generate $DISPLAY .
PuTTY X11 proxy: wrong authorisation protocol attemptedxauth: (argv):1:  unable to open display "localhost:10.0".
Run Code Online (Sandbox Code Playgroud)

顺便说一句,做一个netstat --listen显示端口监听:

tcp 0 0 localhost:6010 *:* LISTEN
Run Code Online (Sandbox Code Playgroud)

AGH,更多信息。我注销了服务器上的 X 会话,现在 .Xauthority 文件消失了。似乎该文件仅在本地登录时才存在。谁能告诉我为什么,或者我该如何解决这个问题?

新发展:

我在名为“test”的系统上创建了一个原始用户。然后我登录,没有任何其他命令,运行 xeyes。哪个有效!所以只有用户“marty”不能xforward。如何将设置从 test 复制到 marty?

ton*_*ton 59

只是为了报告,我确实遇到了类似的问题。但就我而言,我只是按照以下步骤操作

按照以下步骤创建$HOME/.Xauthority文件。

以用户身份登录并确认您位于用户的主目录中。

# Rename the existing .Xauthority file by running the following command
mv .Xauthority old.Xauthority 

# xauth with complain unless ~/.Xauthority exists
touch ~/.Xauthority

# only this one key is needed for X11 over SSH 
xauth generate :0 . trusted 

# generate our own key, xauth requires 128 bit hex encoding
xauth add ${HOST}:0 . $(xxd -l 16 -p /dev/urandom)

# To view a listing of the .Xauthority file, enter the following 
xauth list 
Run Code Online (Sandbox Code Playgroud)

在那之后,.Xauthority文件不再有问题。

感谢srinivasan

  • 第 3 步给了我错误:`xauth: (argv):1: 无法打开显示“:0”。` (32认同)
  • 就我而言,我有一个环境变量 XAUTHORITY 指向其他地方(一个粗心的错误),使用这个 [http://prefetch.net/blog/index.php/2011/11/01/dealing-with-xauth-error -in-locking-authority-file-errors/] 线程我能够发现这一点并解决错误。使用`strace xauth`,它指出了变量中指定的错误路径。我还应该补充一点,我收到了锁定错误以及其他错误 (2认同)

Bas*_*ass 6

只是为了补充优秀答案

我曾经遇到过完全相同的问题,因为我的主目录已 100% 满。连接后,ssh创建了一个空的~/.Xauthority并且无法向其中写入任何单个条目(因此xauth list总是产生一个空的输出)。

因此,我建议一个始终检查可用空间(例如:df -h)并验证xauth generatexauth add的确有任何影响(xauth list)。


小智 5

在 root 权限下打开/etc/ssh/sshd_config并取消注释以下行(如果它们被注释):

X11转发是

X11DisplayOffset 10

X11UseLocalhost 是

然后注销并使用-X标志再次登录ssh。您不必设置或取消设置DISPLAY环境变量。


wkd*_*rty 1

在发现这不是系统之后,通过添加一个测试用户(其中​​ x 转发“开箱即用”),我想我应该开始复制 .bash* 启动文件以将“损坏的”用户处女化。

所有文件都没有不同,因此接下来我删除了用户 .ssh 目录。当我 ssh 登录时,它抱怨“服务器拒绝我们的密钥”,但我可以使用密码登录。登录后,我可以完美转发。

我现在将尝试再次设置密钥,看看是否也能正常工作。然后就会恢复正常。