Chinaunix首页 | 论坛 | 博客
  • 博客访问: 68180
  • 博文数量: 11
  • 博客积分: 610
  • 博客等级: 中士
  • 技术积分: 135
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-08 14:33
文章分类
文章存档

2012年(3)

2011年(1)

2010年(3)

2008年(4)

我的朋友

分类: LINUX

2012-11-20 10:00:26

原来部门服务器是FC5 系统,对于现在Linux分发版的发行速度实在是太老了,yum找不到源,更新、安装软件非常不方便,因此果断换成CentOS 6.2。

为了方便地远程管理服务器,采用终端Xmanager 3(使用XDMCP服务,即X Display Manager Control Protocol,X显示监控协议)。

  • 服务器端配置
1,配置CentOS/RHEL6的gdm,编辑 /etc/gdm/custom.conf(此为gnome桌面管理), 内容修改为如下:

# GDM configuration storage
[daemon]
[security]
DisallowTCP=false
AllowRemoteRoot=true
[xdmcp]
Enable=true
DisplaysPerHost=5
Port=177
[greeter]
[chooser]
[debug]

2,启动gdm,在/etc/inittab中将runlevel设为 5,即:
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
id:5:initdefault:
也可以在shell中直接执行 “init 5” 来启用linux桌面(如果系统是采用init:3的方式启动的话)。
通过 lsof -i:177 命令,可以看到:
$ sudo lsof -i:177
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gdm-binar 2392 root    7u  IPv4  13484      0t0  UDP *:xdmcp 
表示已经成功启动。

  • 客户端Xmanager 配置
1,在Xbrowser中新建一个XDMCP会话

2,按下图所示配置host,method等参数
即可通过新建的session来进行远程连接。

如果你够幸运,通过以上配置就可以远程控制Centos了,但是有的人未必这么幸运,比如我就遇到以下问题。

  • 可能遇到的问题
1,Xmanager连接不上,log如下:
Waiting for client connections ...

Xdmcp: received a WILLING message.
Xdmcp Request Address: 192.168.2.122
Xdmcp Connection Address 0: 192.168.45.112
Xdmcp: sent a REQUEST message.
Xdmcp: received a DECLINE message.
XDMCP fatal error: Session declined Maximum number of open sessions from your host reached
这是由于Xmanager 是经过router 来连接host的,session超出了host 允许的最大值,可以修改XDM的配置:DisplaysPerHost=5。

详细的请参考这篇文章:

===========================================================

Under Linux, this setting is in the /etc/X11/gdm/gdm.conf file and the /etc/kde/kdm/kdmrc file. Here’s the part of the file(s) you need to look at:

[xdmcp]
# Distributions: Ship with this off. It is never a safe thing to leave
# out on the net. Alternatively you can set up /etc/hosts.allow and
# /etc/hosts.deny to only allow say local access.
Enable=true
HonorIndirect
=true
MaxPending
=4
MaxPendingIndirect
=4
MaxSessions
=16
MaxWait
=15
MaxWaitIndirect
=15
DisplaysPerHost
=2
Port
=177
# Willing script, none is shipped and by default we'll send
# hostname system id
Willing=/etc/X11/gdm/Xwilling

Increasing DisplaysPerHost will allow more users to connect before this error happens.

/etc/X11/gdm/gdm.conf configures more host connections for Gnome.

/etc/kde/kdm/kdmrc file configures more host connections for KDE.

===========================================================


2,如果Xmanager在防火墙后面,那么可能连接超时,比如,xbrowser的log可能如下:
Xdmcp Request Address: 192.168.2.122
Xdmcp Connection Address 0: 192.168.6.152
Xdmcp: sent a REQUEST message
Xdmcp: received an ACCEPT message
Xdmcp: sent a MANAGE message.
Xdmcp: Timed out, state 8. Retransmissions: 0
Xdmcp: sent a MANAGE message.
Xdmcp: Timed out, state 8. Retransmissions: 1
Xdmcp: sent a MANAGE message.
Xdmcp: Timed out, state 8. Retransmissions: 2
Xdmcp: sent a MANAGE message.
Xdmcp: Timed out, state 8. Retransmissions: 3
XDM go to sleep: too many retransmissions
User forces server termination. 

而无法建立连接,那么很有可能是客户端本地的防火墙阻止了连接,UDP 177端口用于客户端向服务端发起XDMCP连接,而tcp 6000-6100 端口则用于服务器向客户端传递X。我在我的水星router中加入一个port triggerring rule,当 udp 177发起向外的连接时,对外打开tcp 6000-6100 端口。

解决了以上两个问题,终于可以远程连接X了!


阅读(10745) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~