1. http://celltwo.tistory.com/99 게시글을 확인하면 VNC를 설치하는 법에 대해서 올려두었다.

기본적으로 VNC를 설치하고, 추가로 생성한 계정 openflow에 대해서 추가로 VNC에 접속이 가능하게 할 것이다.



2. SSH 프로그램을 이용하여 vnctest 계정으로 로그인 한다.
Last login: Tue Aug 31 15:37:47 2010 from 192.168.10.20

[openflow@Server ~]$



3. VNC 관련 서비스를 사용하기 위해서 해당 계정에 /home/vnctest/.vnc/ 가 생성이 되도록 VNC를 구동시킨다.

[openflow@Server ~]$  vncserver
 

You will require a password to access your desktops.

Password:
Verify:

New 'NetFPGA3:1 (openflow)' desktop is NetFPGA3:1

 

Creating default startup script /home/openflow/.vnc/xstartup
Starting applications specified in /home/openflow/.vnc/xstartup
Log file is /home/openflow/.vnc/NetFPGA3:1.log

[openflow@Server ~]$




4. root 계정의 Display를 설정 할 때 처럼 X윈도에서 xinitrc 파일을 복사 해왔듯이 openflow 계정 역시 xstartup 파일을 복사한다.

[openflow@Server ~]$ cd .vnc/
[openflow@Server ~]$ mv xstartup xstartup.old
[openflow@Server ~]$ cp /etc/X11/xinit/xinitrc xstartup
[openflow@Server ~]$




5. 기존에 실행중인 VNCSERVER가 있을 수 있으니 강제로 종료한다.

[openflow@Server ~]$ vncserver -kill :1
Killing Xvnc process ID 5732
[openflow@Server ~]$



6. 슈퍼유저(root) 권한으로 VNCSERVER 관련 옵션을 수정한다.

[root@Server ~]# 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:root 2:openflow"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd"
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd"



7. 5900 포트 이후부터 1씩 증가하여 열어준 방화벽에 5902 포트를 열어준다.
5901 포트는 root, 5902 포트는 openflow 계정으로 접속하게 된다.

[root@Server ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 5902 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5902 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5000 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5001 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5001 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT


방화벽에 5901, 5902가 추가가 되었다면 방화벽을 재시작 한다.
(5901의 경우 앞의 게시글에서 추가하였기 때문에 실질적으로 5902 포트만 추가하여준다.)

[root@Server ~]# /etc/init.d/iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: nat filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]
[root@Server ~]#



8. root 계정과 openflow 계정으로 vnc 접속이 가능하게 되었다.
먼저 root 계정으로 접속을 해본다.



위와 같이 root 계정으로 접속을 한 화면을 확인 할 수 있다.



이제 openflow 계정으로 접속을 하도록 한다.







9. 위와 같은 방법으로 추가 계정을 생성하고, VNCviewer를 이용하여 각 계정마다 접속 할 수 있게 설정 할 수 있다.
내가 설치하는 서버에서 VNC를 설치 할 필요가 있어서 정리하고 올린 글이다.

리눅스가 재부팅되면 VNCSERVER는 기본적으로 구동되지 않는다.


VNCSERVER 구동 하는 법

[root@Server ~]# /etc/init.d/vncserver start
Starting VNC server: 1:root
New 'Server:1 (root)' desktop is Server:1

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

2:openflow
New 'Server:2 (openflow)' desktop is NetFPGA3:2

Starting applications specified in /home/openflow/.vnc/xstartup
Log file is /home/openflow/.vnc/Server:2.log

                                                           [  OK  ]
[root@Server ~]#



VNCSERVER 정지 하는 법

[root@Server ~]# /etc/init.d/vncserver stop
Shutting down VNC server: 1:root 2:openflow                [  OK  ]
[root@Server ~]#



VNCSERVER 재시작 하는 법

[root@Server ~]# /etc/init.d/vncserver restart
Shutting down VNC server: 1:root 2:openflow                [  OK  ]
Starting VNC server: 1:root
New 'Server:1 (root)' desktop is Server:1

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

2:openflow
New 'Server:2 (openflow)' desktop is Server:2

Starting applications specified in /home/openflow/.vnc/xstartup
Log file is /home/openflow/.vnc/Server:2.log

                                                           [  OK  ]
[root@Server ~]#



10. setup 명령어로 서비스를 추가하면, 부팅과 동시에 VNCSERVER가 구동되기 때문에 따로 명령어를 주지 않아도 되는 편리한 점이 있다.

SSH 프로그램이나 VNCSERVER에 root 계정으로 접속하여 setup 명령을 주면 되는데, VNCSERVER에 터미널 창을 열어주고 setup 명령어를 실행하면 아래와 같은 메뉴를 볼 수 있다.

System services 메뉴를 들어 간다.



vncserver 항목을 스페이스바를 눌러 체크한다.
(체크가 되면 *를 표시하게 되며, TAB 키를 이용하여 Ok에서 엔터키를 입력한다)



Quit에서 엔터를 치면 터미널창으로 돌아가게된다.
이후부터 서버가 재부팅 되더라도 VNCSERVER를 시작하지 않더라도 VNC 접속이 가능하게 된다.
블로그 이미지

쭈꾸댕이

아직 어설픈 실력으로 나름 제가 하는 것에 대한 것들을 옮기는 공간입니다. 틀린 부분도 있을 수 있으니 이 점 양해하시고, 도움이 되셨으면 좋겠네요.

,






1. VNC 서버가 설치되었는지 확인한다.

[root@Server ~]# rpm -qa vnc
vnc-4.1.2-14.el5_5.4
[root@Server ~]#




2. VNC 사용자를 설정한다.

[root@Server ~]# 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"


아래와 같이 계정을 추가한다.

# 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 -nolisten tcp -nohttpd"


vncservers 파일은 기본 내용이 들어있으며 입맛에 맞게 설정을 하면 된다.
기본적으로 X윈도가 0번 화면을 사용하므로 0번이 아닌 다른 번호를 사용해야 에러 없이 사용이 가능하다.
0번으로 설정하면 로컬에서 X윈도를 사용할 수 없게되어 1번을 사용하면서 다른 프로그램에 영향을 줄 수 있으므로 1번 설정을 한다.

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd"


# 으로 된 주석을 지우거나 새로 추가하면 된다.
VNCSERVERS="1:root"와 VNCSERVERARGS[1]는 동일한 숫자를 넣어주었으며 0번보다 큰 숫자를 입력하였다.

-localhost 역시 삭제하였는데 로컬에서만 접속하는 옵션이므로, 원격 제어를 가능하게 하기 위해서 삭제하였다.

마지막으로 800x600의 해상도에서 1024x768으로 변경하였다.




3. 방화벽에 VNC를 추가하여 준다.

VNC의 포트번호는 5900번이며 X윈도 화면번호를 더해준 값이 실제로 사용하는 포트 번호이다.
위에서 설정한 것을 바탕으로 5900번에 1번을 더한 5901번으로 설정하면 된다.

[root@Server ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5000 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5001 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5001 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 6633 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 6633 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT


아래와 같이 추가한다.

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5901 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5000 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5001 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5001 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 6633 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 6633 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT


방화벽을 다시 시작하여 추가한 포트가 열리도록 한다. 
[root@Server ~]# service iptables restart
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[  OK  ]

[root@Server ~]#




4. VNC를 접속 할 때 사용할 패스워드를 설정한다.

[root@Server ~]# vncpasswd
Password:
Verify:

[root@Server ~]#




5. VNC 서버를 가동한다.

VNC가 동작하고 있는지 확인을 하고, 동작하지 않는다면 실행시킨다.
[root@Server ~]# service vncserver status
Xvnc is stopped
[root@Server ~]#

동작하지 않으므로, 아래와 같은 명령으로 동작 시킨다.
[root@Server ~]# service vncserver start
Starting VNC server: 1:root xauth:  creating new authority file /root/.Xauthority

New 'Server:1 (root)' desktop is Server:1

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

                                                           [  OK  ]
[root@Server ~]#

정상적으로 동작하고 있는지 다시 확인한다.
[root@Server ~]# service vncserver status
Xvnc (pid 14733) is running...
[root@Server ~]#




6. VNC 서버가 제대로 동작하고 있는지 접속하여 확인한다.


VNC Viewer를 이용하여 접속을 하는데 Server라고 된 부분에 해당 서버의 주소를 입력하고, :5901은 위에서 설명한대로 VNC가 사용 할 포트번호이다.



위에서 설정한 패스워드를 입력하여 VNC에 접속을 한다.


위와 같은 기본 X윈도의 화면을 출력할 것이다.
설정이 전혀 되어있지 않으므로 원격제어를 하기 위한 화면과 다소 거리가 멀다.




7. 원격으로 접속 할 때 X윈도를 로컬에서 보듯이 변경하는 설정을 한다.

[root@Server ~]# pwd
/root
[root@Server ~]# cd .vnc/
[root@Server .vnc]# mv xstartup xstartup.old
[root@Server .vnc]# cp /etc/X11/xinit/xinitrc xstartup
[root@Server .vnc]# service vncserver restart
Shutting down VNC server: 1:root                           [  OK  ]
Starting VNC server: 1:root
New 'Server:1 (root)' desktop is Server:1

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

                                                           [  OK  ]
[root@Server .vnc]#

홈디렉토리( /root )를 확인하고 .vnc 디렉토리에 있는 xstartup 이라는 설정 관련 내용을 로컬 서버의 X윈도에서 사용되는 xinitrc 파일을 복사하는 과정이다. VNC 서비스를 재시작하여 바뀐 설정을 불러온다.




8. VNCviewer를 이용하여 서버에 다시 접속한다.

위 그림과 같이 로컬에서 보는 화면과 동일한 화면으로 로컬 서버를 제어 할 수 있다.



'Linux tools > VNC' 카테고리의 다른 글

다수의 계정으로 한 서버에 VNC 접속하는 법  (0) 2010.08.31
블로그 이미지

쭈꾸댕이

아직 어설픈 실력으로 나름 제가 하는 것에 대한 것들을 옮기는 공간입니다. 틀린 부분도 있을 수 있으니 이 점 양해하시고, 도움이 되셨으면 좋겠네요.

,