Linux下搭建VNC服務器

Linux下搭建VNC服務

1.系統環境

Redhat5.5 x86_64

2.查看是否已安裝vncserver

#rpm -qa | grep vnc

vnc-server-4.1.2-14.el5_3.1

vnc-4.1.2-14.el5_3.1

3.切換至普通用戶

#su – xue

4.設置xue用戶登錄VNC密碼

vncpasswd

Password:

Verify:

5.配置vnc-server配置文件

cat  /etc/sysconfig/vncservers | grep -v"^#" | grep -v "^$"

VNCSERVERS="1:xue"

VNCSERVERARGS[1]="-geometry 800x600-nolisten tcp -nohttpd -localhost"

(也即把最後兩行#去掉,修改一下用戶名即可若需要支持多用戶,使用空格隔開)

6.啓動vncserver

/sbin/servicevncserver restart

Shuttingdown VNC server: 1:xue                           [FAILED]

StartingVNC server: 1:xue xauth:  creating newauthority file /home/xue/.Xauthority

xauth:(stdin):1:  bad display name"ihs:1" in "add" command


New'ihs:1 (xue)' desktop is ihs:1


Creatingdefault startup script /home/xue/.vnc/xstartup

Startingapplications specified in /home/xue/.vnc/xstartup

Logfile is /home/xue/.vnc/ihs:1.log


                                                         [  OK  ]

7.配置vncserver,使客戶端可以使用桌面環境

cat~/.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&

8.重啓vncserver

#/sbin/service vncserver restart

Shuttingdown VNC server: 1:xue                            [  OK  ]

StartingVNC server: 1:xue xauth: (stdin):1:  baddisplay name "ihs:1" in "add" command


New'ihs:1 (xue)' desktop is ihs:1


Startingapplications specified in /home/xue/.vnc/xstartup

Logfile is /home/xue/.vnc/ihs:1.log


                                                          [  OK  ]

9.查看端口

#netstat -tlunp

ActiveInternet connections (only servers)

ProtoRecv-Q Send-Q Local Address              Foreign Address            State       PID/Program name

tcp        0     0 0.0.0.0:5801                0.0.0.0:*                   LISTEN      1824/Xvnc

tcp        0     0 0.0.0.0:5901                0.0.0.0:*                   LISTEN      1824/Xvnc

tcp        0     0 0.0.0.0:6001                0.0.0.0:*                   LISTEN      1824/Xvnc

tcp        0     0 :::6001                     :::*                        LISTEN      1824/Xvnc

tcp        0     0 :::22                      :::*                        LISTEN      1592/sshd

10.查看進程

#ps -ef | grep vnc | grep -v grep

xue       1824    1  0 16:31 ?        00:00:00 Xvnc :1 -desktop ihs:1 (xue)-httpd /usr/share/vnc/classes -auth /home/xue/.Xauthority -geometry 1024x768-depth 16 -rfbwait 30000 -rfbauth /home/xue/.vnc/passwd -rfbport 5901 -pn

#ps aux | grep vnc | grep -v grep

xue       1824 0.1  0.3  47812 7552 ?        S    16:31  0:00 Xvnc :1 -desktop ihs:1 (xue) -httpd /usr/share/vnc/classes -auth/home/xue/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth/home/xue/.vnc/passwd -rfbport 5901 –pn

11.查看日誌是否無誤

12.客戶端登錄測試


輸入用戶名和密碼

登錄即可。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章