다음 이전 차례

12. 보안

Beowulf 클러스터의 일반적인 보안정책은 클러스터내의 모든 노드가 서로를 신뢰할 수 있어야한다는 것이다. 클러스터내의 보안에 여러분이 안심할 수 있는 이유는 클라이언트 노드 어떠한 것도 외부와 직접연결이 되어 있지 않고 모든 노드들이 기본적으로 동일하기 때문이다. 만일 누군가가 게이트웨이를 해킹(역자주: 크래킹이 정확한 명칭)하려 한다면 크래커들은 클라이언트 노드에 대한 정보는 전혀 얻을 수 없어서 이러한 수준에서는 보안문제를 걱정할 필요가 없다. 누군가가 여러분의 노드의 콘솔에 있지 않고 서버노드를 거치지 않고 노드에 접속을 한다는 것은 불가능한 일이다. 클러스터내의 보안을 완화시키는 가장 큰 장점은 유연성이고 사용하기 쉽고 관리하기 쉽다는 점이다. 이와는 달리 서버노드는 클라이언트 노드를 믿어야하지만 외부세계는 믿어서는 안된다. 클러스터내의 보안을 완화시키고 외부로부터 여러분 자신을 지키는 방법은 몇가지 있다.

12.1 서버

TCP wrapper

일반적으로 TCP wrapper로 알려진 tcpd 데몬은 방어의 제1선이고 여러분의 머신에 접속을 제한하는 가장 간단한 방법이어서 시스템의 보안성을 높인다. 이는 Red Hat 배포본의 일부분으로 나와있고 설정이 간단하다. 세가지 설저파일들이 있다: /etc/hosts.allow는 연결을 허락하는 호스트를 확인한다. /etc/hosts.deny/etc/hosts.allow에 나타나지 않은 목록이 있으면 읽어드린다. 연결을 거부하는 호스트를 확인한다. /etc/inetd.conf는 tcpd를 설정할 때 변경할 필요없는 것들이 있다. host_access(5) man 페이지는 /etc/hosts.allow/etc/hosts.deny의 문법에 관한 내용에 대한 좋은 정보를 준다.

Allowing access with /etc/hosts.allow 아래의 예는 IP 주소가 10.0.0.x, 10.1.x, 10.0.2.x에서 들어오는 어떠한 포트도 연결을 허락한다는 의미이다. 또한 myworkstation.usq.edu.au의 호스트로 부터오는 것도 접속을 허락한다는 의미이다. 모든 다른 접속은 /etc/hosts.deny파일에 의해서 막히고 서비스들은 /etc/inetd.conf에 목록화되어 있으며, tcpd를 통해서 설정이 시작된다.


#
# hosts.allow   This file describes the names of the hosts which are 
#               allowed to use the local INET services, as decided 
#               by the '/usr/sbin/tcpd' server
#

# we fully trust ourself and all the other nodes within the cluster

ALL : localhost, 10.0.0., 10.0.1., 10.0.2.
in.telnetd : myworkstation.usq.edu.au

/etc/hosts.deny를 이용한 접근거부 /etc/hosts.deny파일은 /etc/hosts.allow파일에서 일치하지 않는 호스트를 확인한다. TCP wrapper를 이용하는 가장 좋은 방법은 /etc/hosts.allow에서 허락하지 않는 모든 호스트를 거부하는 것이다. 저자의 경우 /etc/hosts.deny와 일치하지 않는 것은 물론 이거니와 모든 것의 접근을 거부시켜 놓았다. 모든 거부된 연결에 대해서는 관리자에게 자세한 내용을 이메일로 보낸다.


ALL: ALL: spawn ( \
echo -e "\n\
TCP Wrappers\:  Connection Refused\n\
By\:                    $(uname -n)\n\
Process\:               %d (pid %p)\n\
User\:                  %u\n\
Host\:                  %c\n\
Date\:                  $(date)\n\
" | /bin/mail -s "From tcpd@$(uname -n).  %u@%h -> %d." root)

만일 연결이 /etc/hosts.allow에서 나와있지 않는 호스트로부터 시도된다면 /etc/hosts.deny에서 연결을 거부할 것이며 거기에 따른 이메일을 저자는 받게 될 것이다. 그러한 이메일의 내용은 다음과 같다.


From root       Fri Apr 16 23:33:50     1999
Return-Path: <root>
             by topcat.beowulf.usq.edu.au (8.8.7/8.8.7) id XAA19278
             for root; Fri, 16 Apr 1999 23:33:50 +1000
Date: Fri, 16 Apr 1999 23:33:50 +1000
From: TOPCAT Admin <root@topcat.beowulf.edu.au>
Message-Id: <199904161333.XAA19278@topcat.beowulf.usq.edu.au>
To: root@topcat.beowulf.edu.au
Subject: From tcp@topcat.beowulf.usq.edu.au.   jacek@lamport.comp.usq.edu.au -> in.telnetd.
Status: 0

TCP Wrappers: Connection Refused
By:             topcat.beowulf.usq.edu.au
Process:        in.telnetd (pid 19270)
User:           jacek
Host:           jacek@lamport.comp.usq.edu.au
Date:           Fri 16 Apr 1999 23:33:50 EST 1999

사용하지 않는 데몬 멈추기 - /etc/inetd.conf

아주 단순 하지만 효과적인 서버보안의 한가지 방법은 사용하지 않는 데몬을 멈추는 것이다. 일반적으로 여러분이 사용하지 않는 것은 멈추는 것이 좋다. 대부분의 데몬이 inetd에 의해 작동이 되고 /etc/inetd.conf의 내용에서 사용하지 않는 데몬을 주석처리 해주면 작동하지 않는다. 다음의 예는 /etc/inetd.conf의 login, exec, talk과 ntalk의 예를 보여주는 것이다.


shell   stream  tcp     nowait  root    /usr/sbin/tcpd  in.rshd
#login   stream  tcp     nowait  root    /usr/sbin/tcpd  in.rlogind
#exec   stream  tcp     nowait  root    /usr/sbin/tcpd  in.rexecd
#comsat dgram   udp     wait    root    /usr/sbin/tcpd  in.comsat
#talk   dgram   udp     wait    nobody.tty      /usr/sbin/tcpd  in.talkd
#ntalk  dgram   udp     wait    nobody.tty      /usr/sbin/tcpd  in.ntalkd

설정파일을 변경한 후에 다시 inetd데몬을 시작한다. 리눅스에서 가장 손쉬운 방법은 설정파일을 다시 읽어 드리게 데몬에게 신호를 주는 것이다.

[root@topcat root]# killall -HUP inetd

다른 유닉스 시스템에서는 kill을 잘 읽고 수행하라!

여러분은 모든 포트의 목록을 가지고 어떤 데몬이 수행되고 있는지를 확인할 수 있다. 다음 명령으로 이 목록을 얻을 수 있다.

[root@topcat root]# netstat -a | grep "LISTEN" | grep -v "^unix"

rc 스크립트를 이용하여 서버멈추기

웹서버(http)와 같은 서버와 삼바(smbd)는 rc 스크립트로서 작동한다. 보통 각각은 /etc/rc.d/rc3.d에 있는 각각에 해당하는 링크를 제거함으로써 작동을 멈추게된다. 예를 들어 httpd, samba와 sendmail(또다른 보안프로그램)dms run level 3과 5을 작동시킴으로써 다음과 같이 할 수 있다.


[root@topcat samba]# rm -f /etc/rc.d/rc/3d/S*httpd
[root@topcat samba]# rm -f /etc/rc.d/rc/5d/S*httpd
[root@topcat samba]# rm -f /etc/rc.d/rc/3d/S*smb
[root@topcat samba]# rm -f /etc/rc.d/rc/5d/S*smb
[root@topcat samba]# rm -f /etc/rc.d/rc/3d/S*sendmail
[root@topcat samba]# rm -f /etc/rc.d/rc/5d/S*sendmail

ipfwadm

ipfwadm프로그램은 특정 IP 주소에서부터 특정 포트까지 패킷을 막는역할을 한다. 이는 보안을 제어하는 가장 유연한 방법이다. 예를 들어 firewall (17절 (firewall_script)) rc 스크립트는 반드시 시스템이 시작할 때 같이 시작되어야 하고 다음과 같이 하면된다.

[root@topcat init.d]# cp /home/jacek/firewall /etc/rc.d/init.d
[root@topcat init.d]# chmod u+rx firewall
[root@topcat init.d]# ln -s /etc/rc.d/init.d/firewall /etc/rc.d/rc3.d/S05firewall
[root@topcat init.d]#ln -s /etc/rc.d/init.d/firewall /etc/rc.d/rc5.d/S05firewall

NOTE: 여러분은 여러분의 환경에 맞게 저자의 스크립트를 바꾸어야한다.

12.2 클라이언트

.rhosts versus hosts.equiv

사용자들이 하고싶어 하는 것중의 하나는 패스워드없이 노드간에 접속을 하고 원격명령을 내리는 것이다. 대부분의 Beowulf 소프트웨어와 유틸리티들은 여러분이 rsh로 작동하게 만들어 패스워드 없이 작업하게 만든다.

클러스터내의 패스워드를 없애는 두가지 방법이 있는데 하나는 /etc/hosts.equiv에 입력하는 것이고, 다른 하나는 사용자 각자의 디렉토리에 .rhosts를 첨가하는 것이다.

/etc/hosts.equiv가 모든 노드에 .rhosts에 있는 내용을 모아서 하나의 파일로 적용될 수 있기에 많이 선호된다.

다음의 형태는 .rhosts에 있는 호스트의 목록이다:


# must be read/writable by user only!
node1
node2
node3
node4
node5
node6

/etc/hosts.equiv의 형태는:


#node name      optional user name
node1
node2
node3
node4
node5
node6

root rlogin 접근:

root가 클러스터내의 어떠한 노드에도 rlogin하기 위해서는 각노드의 root 디렉토리에 .rhosts를 첨가해야합니다. .rhosts파일은 클러스터내의 모든 노드들을 명기하고 있어야합니다. 중요한점: .rhosts는 반드시 사용자만이 읽고 쓸 수 있어야합니다. ( chmod go-rwx .rhosts) 이는 게이트웨이 노드에서는 해서는 안됩니다.

추가로 /etc/pam.d/rlogin:의 처음 두줄을 바꿔줍니다.


#orginal /etc/pam.d/rlogin
auth     required       /lib/security/pam_securetty.so
auth     sufficient     /lib/security/pam_rhosts_auth.so
auth     required       /lib/security/pam_pwdb.so shadow nullock
auth     required       /lib/security/pam_nologin.so
account  required       /lib/security/pam_pwdb.so
password required       /lib/security/pam_cracklib.so
password required       /lib/security/pam_pwdb.so shadow nullock
                                                   use_authtok
session  required       /lib/security/pam_pwdb.so

#first two lines are swapped /etc/pam.d/rlogin
auth     sufficient     /lib/security/pam_rhosts_auth.so
auth     required       /lib/security/pam_securetty.so
auth     required       /lib/security/pam_pwdb.so shadow nullock
auth     required       /lib/security/pam_nologin.so
account  required       /lib/security/pam_pwdb.so
password required       /lib/security/pam_cracklib.so
password required       /lib/security/pam_pwdb.so shadow nullock
                                                   use_authtok
session  required       /lib/security/pam_pwdb.so

NOTE: 더 나은 방법이 있는지는 모르겠지만 작동은 한다.

root telnet 접근

게이트웨이 노드를 제외한 모든 노드에 /etc/securetty 파일에 다음과 같은 내용을 첨가한다:


ttyp0
ttyp1
ttyp2
ttyp3
ttyp4

이러한 변화는 remote telnet을 이용 클러스터내의 어떠한 노드로 연결 이 가능케하는 것이다.

root ftp 접근

root의 ftp 접근이 필요한 시스템의 경우, /etc/ftpusers 파일에 다음과 같이 root 부분에 주석을 단다.


#Comment out root to allow other systems ftp access as root
#root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody


다음 이전 차례