---
title: "RHEL6上ssh -X打不开图形化窗口(Remote: No xauth program; cannot forward with spoofing.)"
author: "kouriba"
date: "2012-08-19T22:46:00Z"
tags: []
slug: "rhel6-ssh-x-remote-no-xauth-program-cannot-forward-with-spoofing"
draft: false
lastmod: "2012-08-20T14:07:26Z"
id: 1638284
url: "https://kouriba.iteye.com/blog/1638284"
---

\[root@localhost ~]# lsb\_release -a  
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch  
Distributor ID: RedHatEnterpriseServer  
Description: Red Hat Enterprise Linux Server release 6.0 (Santiago)  
Release: 6.0  
Codename: Santiago

254装了图形化，168默认没装图形化，254 ssh -X到168，发现打不开图形界面，发现原因竟是168上少装了一个xauth的包。

**strace xhost发现报如下错：**

strace xhost +  
...  
connect(3, {sa\_family=AF\_INET, sin\_port=htons(6000), sin\_addr=inet\_addr("10.100.0.254")}, 16) = -1 ECONNREFUSED (Connection refused)

...

**ssh -vvv发现是xauth的问题：**  
ssh 10.100.0.168 -X -vvv  
...  
debug3: Wrote 512 bytes for a total of 2005  
debug1: Remote: No xauth program; cannot forward with spoofing.  
debug2: channel\_input\_status\_confirm: type 99 id 0  
...

**安装xauth：**

yum install xauth -y

**再次-X登陆，注意最后一行，xauth在用户家目录下创建了一个.Xauthority的文件：**

\[root@401x Desktop]# ssh 10.100.0.168 -X  
root@10.100.0.168's password:  
Last login: Sun Aug 19 21:05:08 2012 from 10.100.0.254  
/usr/bin/xauth: creating new authority file /root/.Xauthority

**发现已经可以打开图形界面：**

\[root@localhost ~]# xclock  
Warning: Missing charsets in String to FontSet conversion

**回过头来看下ssh -vvv：**

ssh 10.100.0.168 -X -vvv  
...  
debug3: Wrote 128 bytes for a total of 1381  
debug2: callback start  
debug2: x11\_get\_proto: /usr/bin/xauth list :0.0 2&gt;/dev/null  
debug1: Requesting X11 forwarding with authentication spoofing.  
debug2: channel 0: request x11-req confirm 0  
...

原本以为是xhost和DISPLAY变量设置的问题，结果发现与二者没有任何关系。

装了xauth后，168上的DISPLAY如下，xhost和DISPLAY变量都未做任何改动。

\[root@localhost ~]# echo $DISPLAY  
localhost:10.0

REF:

1\. xhost doesn't work

http://forums.gentoo.org/viewtopic-t-424675-start-0.html

2\. No xauth Program; Cannot Forward With Spoofing Error and Solution

http://www.cyberciti.biz/faq/linux-unix-appleosx-noxauth-program-cannot-forward-with-spoofing/