由于身份验证错误,X11连接被拒绝

时间:2014-06-30 14:45:34

标签: x11 x11-forwarding

使用X11Forwarding访问firefox时出错。

[root@station2 ~]# firefox
KiTTY X11 proxy: wrong authorisation protocol attemptedKiTTY X11 proxy: wrong authorisation protocol attemptedError: cannot open display: localhost:10.0

设置以下值:/ etc / ssh / sshd_config

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

**安装包**

#yum install xorg-x11-xauth
#yum -y install xauth

[root@station2 .ssh]# echo $DISPLAY
localhost:10.0

#mkxauth -c
adding key for station2.example.com to /root/.Xauthority ... done

3 个答案:

答案 0 :(得分:7)

There is a hard, if not even impossible, to find (by search engine) scenario that may may cause that error message.

Preliminary note: The topic of this answer is not to discuss if it is a safety risc or recommondable at all to use a graphical desktop as root on an remote, display-less, webserver.

Scenario:

  • A remote internet connected Linux server S has assigned the domain name example.com to it's public IP4-address 192.0.2.1.
  • The /etc/hostname file on S contains the single line example.
  • The /etc/hosts file on S contains the line 127.0.0.1 localhost example.com example.
  • The (remote) ssh access to S is by (sshd-) configuration (on S) forbidden for root by the line DenyUsers root in /etc/ssh/sshd_config, but allowed for a dummy user user1. From a client computer C a ssh connection, using the ssh parameter -X or -Y, is established to S as user user1.

Then, in a remote terminal on S owned by user1, if any X11 related command is tried to be executed as root, may it be by

su, then trying to start the X11 desktop environment

or, as in the concrete case executing a script containing

#!/bin/bash
su --preserve-environment -c "xfce4-session &" root

the error message

X11 connection rejected because of wrong authentication.

is output and the start of any X11 related program fails. The DISPLAY variable of root's environment contains

example.com:10.0

then.

One solution to the problem is, in this special case, to modify the line

127.0.0.1 localhost example.com example

in /etc/hosts to

127.0.0.1 localhost

答案 1 :(得分:2)

解决方案:使用您正在进行SSH连接的用户运行应用程序。

使用X11时我也遇到过这样的错误。

我的问题的根源是我使用SSH和我自己的用户名(不是root用户)。

然后,登录后我厌倦了使用X11运行的东西,同时做" su"或做" sudo", 问题是SSH会话配置了你自己的用户名 - 例如:Raj,但是你切换到用户root,这不是X11会话的一部分。

所以你应该做的只是尝试使用你启动X11会话的同一个用户运行应用程序(在你的情况下是firefox)。

希望这有帮助。

Talel。

答案 2 :(得分:0)

export XAUTHORITY=$HOME/.Xauthority

此修复程序对我有用