Linux/CentOS2012. 8. 31. 09:38

CentOS 5.5 에는 기본적으로 VNC Server가 설치되어 있어 환경설정과 서비스 등록만으로 VNC를 사용할 수 있다.

만약, 설치되지 않은 경우, 아래와 같이 설치한다.

 

일단, CentOS가 설치된 서버에 GUI가 설치되어 있어야 한다.

만약, 설치되어 있지 않다면 다음과 같이 명령하여 설치한다.

yum groupinstall "X Window System" "KDE Desktop"

 

VNC 소프트웨어를 설치한다.

yum install tigervnc-server



1. 환경

- CentOS 5.5  : 설치됨
- VNC Viewer : http://www.uvnc.com/download/ 에서 다운로드



2. 설정

# vi /etc/sysconfig/vncservers



3. 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 12800x800"

만약, root가 아닌 사용자ID로 사용을 하고자 하는 경우,

root를 사용자ID로 수정 후, 저장하고,

아래의 암호설정 시에도 su상태가 아닌 사용자ID 상태에서 설정해야 한다.

4. VNC 암호 설정

# vncpasswd
Password:
Verify:



5. Port 확인 및 방화벽 오픈

# netstat -antp
 

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name

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

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

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      2629/portmap

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



# vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
  (추가)



5-1. iptable restart

# /etc/rc.d/init.d/iptables restart



6. VNC Server 시작

# service vncserver start


 
7. 서버 부팅시 자동 실행 service로 등록

# chkconfig vncserver on


  
8. 윈도우에서 그래픽모드로 보기 위한 설정

# vi /root/.vnc/xstartup



#!/bin/sh


wing 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 &


# 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 &





9. VNC Viewer로 접속 확인 



10. 접속화면





11. 참고

http://jonnychoe.egloos.com/5472045

Posted by iWithJoy