2009년 7월 10일 금요일

[리눅스] 리눅스를 원격제어 해보자!~

리눅스에서도 윈도우처럼 x-window을 원격제어 할 수 있다.

물론 여러가지 프로그램들이 있지만, 우선 여기에서 VNC를 이용하여 원격제어를

하고자 한다.


1. VNC SERVER가 설치가 되어있는지 확인을 해본다.

#rpm -qa|grep vnc
vnc-server-4.1.2-9.el5

2.  VNC가 설치가 되어 있다면 VNC 설정파일에서 사용자를 추가해준다.

#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="1:user"             #이부분의 주석을 제고하고 사용하고자하는 사용자를 등록한다. 사용자앞은 숫자는 접속할때 필요한 것이므로 유의하여 등록한다.
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

3. VNC를 실행을 위한 준비작업.

  - 환경설정

# vncserver :1
Starting VNC server: 1:user
New 'linux.user:1(user)' desktop is linux.user:1

starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/linux.user:1.log

위 명령을 실행하면 x-windows를 선택할 수 있는 필요 파일들이 생성된다.

= 아래 설정파일에서 빨간색으로 표시된 부분을 주석을 제거해줘야
GUI 원격제어를 할수가 있다.. 이게 주석처리되있으면 터미널모드만 실행가능한
원격제어가 된다..(그럴거면 SSH 접속 프로그램이 오히려 더 편하다..)

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

   - VNC 실행

실행된 VNC 서버가 있다면 설정을 변경한후 재기동을 해준다. 이때 재기동을 해주어야 변경된 환경설정되로 변경된다.
[root@ ~] service vncserver restart

#vncserver -kill :1             
Killing Xvnc process ID 1234

#vncserver :1
Starting VNC server: 1:user
New 'linux.user:1 (user)' desktop is linux.user:1

starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/linux.user:1.log

이제 모든작업을 완료하였다.

그럼 이제 클라이언트에서 접근해보자.

출처 : http://ggwangs.egloos.com/870506

댓글 없음:

댓글 쓰기