RHL配置VNC Server

iteye_20954發表於2011-12-15
RHL配置VNC Server

0. 啟動vncserver服務
[root@localhost ~]# service vncserver status
Xvnc 已停
[root@localhost ~]# service vncserver start
啟動 VNC 伺服器:no displays configured [確定]
1. 開啟vncserver服務端
[root@localhost ~]# vncserver :1

You will require a password to access your desktops.

Password:
Verify:

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
2. 修改vnc顯示方式
預設情況下是shell,下面設定使用xwindows方式登入到遠端linux,將預設的twm &註釋掉,增加一行gnome-session &,使用的是GNOME桌面,還有KED方式:startkde&。
[root@localhost ~]# vi /root/.vnc/xstartup
[root@localhost ~]# cat /root/.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 &
如果要立即生效連線桌面方式,需要重啟服務:
[root@localhost ~]# vncserver -kill :1
Killing Xvnc process ID 8135
[root@localhost ~]# vncserver :1
檢視下監聽狀態:
[root@localhost ~]# netstat -tulnp
3. 在客戶端連線
192.168.2.203:5901 http://192.168.2.203:5801
4. 配置vncserver自啟動
[root@localhost ~]# chkconfig --list vncserver
vncserver 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
[root@localhost ~]# chkconfig --level 2345 vncserver on
[root@localhost ~]# chkconfig --list vncserver
vncserver 0:關閉 1:關閉 2:啟用 3:啟用 4:啟用 5:啟用 6:關閉
修改開機啟動服務程式
[root@localhost ~]# vi /etc/sysconfig/vncservers
[root@localhost ~]# cat /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="1:root"
VNCSERVERARGS[1]="-geometry 1024x768"

-The End-

相關文章