歡迎您光臨本站 註冊首頁

解決本地linux 作為x server的問題

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0
一直以來,很納悶,為什麼我的本地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 root@192.168.1.103
註釋:記住是大寫的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 作為x server的問題已經有972次圍觀

http://coctec.com/docs/linux/show-post-55056.html