解决本地linux 作为x server的问题

一直以来,很纳闷,为什么我的本地FC9就不能作为remote的X Server呢,每次运行GUI程序,都会报错:
Error: Can't open display: ip:0.0

今天终于找到问题了,原因是我登录远程系统使用的是ssh,而ssh默认是关闭x显示的,所以要想在本地运行远程的GUI程序,必须在登录的时候就带上参数-X
实现步骤:
第一步:在本地的FC9上允许x client显示,使用命令xhost +(或者xhost + remote ip[hostname]),解禁访问控制
[user@myfc9]xhost +
access control disabled, clients can connect from any host

            如果要进制x client程序显示的话,就是用xhost -(或者xhost -remote ip[hostname]);
第二步:ssh到远端机器,不须带上参数-X
[user@myfc9]ssh -X [email protected]   
注释:记住是大写的X,小写的x恰好是进制x 程序显示
第三步:登录到remote后,在命令行指定显示服务器,使用命令export DISPLAY
[root@vmware]export DISPLAY=192.168.1.105 :0.0  
#(192.168.1.105为本地X Server IP address,在我这就是我自己的笔记本上的FC9的ip地址)
第四步:检查指定的显示服务器地址是否正确
[root@vmware]echo $DISPLAY
192.168.1.105:0.0       #ok
第五步:测试GUI程序显示,随便用一个GUI程序,我常用的是xclock
xclock
ok,在本地就显示出了vmware中的时钟显示。

附:命令帮助:
1.xhost
usage: xhost [[+-]hostname ...]
2.ssh
usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-i identity_file] [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-w tunnel:tunnel] [user@]hostname [command]

参数 X/x
-X      Enables X11 forwarding.  This can also be specified on a per-host
             basis in a configuration file.

             X11 forwarding should be enabled with caution.  Users with the
             ability to bypass file permissions on the remote host (for the
             user’s X authorization database) can access the local X11 display
             through the forwarded connection.  An attacker may then be able
             to perform activities such as keystroke monitoring.

             For this reason, X11 forwarding is subjected to X11 SECURITY
             extension restrictions by default.  Please refer to the ssh -Y
             option and the ForwardX11Trusted directive in ssh_config(5) for
             more information.

     -x      Disables X11 forwarding.


你可能感兴趣的:(linux,server,X-window,休闲,X)