Linux下配置VNC

來源:互聯網
上載者:User

標籤:manage   不能   table   pair   port   enter   防火牆   listen   starting   

環境: REDHAT 5


1. 檢查是否安裝了VNC:
rpm -qa vnc-server

vnc-server-4.1.2-9.el5


沒安裝的話。安裝一下:
yum install vnc-server


2. 配置vncserver登入password:
[[email protected] ~]# vncserver


You will require a password to access your desktops.


Password:
Verify:
xauth:  creating new authority file /root/.Xauthority

New ‘Redhat:1 (root)‘ desktop is Redhat:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Redhat:1.log


3. 配置vncserver開機檔案:
vi ~/.vnc/xstartup

改動後檔案:


#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
# twm &
gnome-session &


4. 配置vncservers檔案
vi /etc/sysconfig/vncservers
改動後檔案:
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername‘ (adjust this to your own).  You will also
# need to set a VNC password; run ‘man vncpasswd‘ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-nohttpd" to prevent web-based VNC clients connecting.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer‘ manual page.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd -localhost"


5. 關閉防火牆
service iptables stop
或者開放VNCport:
/sbin/iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 5900:5903 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart


6. 殺掉當前進程:
vncserver -kill :1
vncserver -kill :2 
...

7. 啟動vncserver
[[email protected] ~]# vncserver

New ‘Redhat:1 (root)‘ desktop is Redhat:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Redhat:1.log



8. 通過瀏覽器(JAVA)串連:
http://192.168.65.131:5801/




9. 通過VNC Viewerclient串連:
192.168.65.131:1


依據提示輸入前面配置的登入password就可以開啟!




PS:可能出現的問題:


a、黑屏
在Linux裡安裝配置完VNC服務端,發現多使用者登陸會出現黑屏的情況,詳細的現象為:
client能夠通過IP與會話號登陸進入系統,但登陸進去是漆黑一片。除了一個叉形的滑鼠以外,伸手不見五指。


原因:使用者的VNC的開機檔案許可權未設定正確。


解決方案:將黑屏使用者的xstartup(一般為:/home/username稱/.vnc/xstartup)檔案的屬性改動為755(rwxr-xr-x)。




b、vnc 能輸入數字,但不能輸入字母
原因:vnc server這邊會要求vnc viewer這邊OS的IME要和vnc server那邊OS的語言要一致。


解決方案:一般我們裝的Linux OS都是E文的,所以使用vnc viewer連入的時候,請關閉本地OS的中文IME。切換到英語就能夠了。


--------------------------------

Dylan    Presents.



Linux下配置VNC

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.