32
* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System ) 1/32 페이지 서 진우([email protected]) 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치 1.4 운영체제 기본 보안 설정 Linux 운영체제는 Open Source 기반 운영체제입니다. Open Source 기반의 운영체제라는 조건이 실제 시스템 운영 측점에서 장점이 될수도 있고, 단점이 될 수도 있는데 대표적인 것이 바로 운영체제 보안이라 볼 수 있습니다. 운영체제의 Source code 가 공개되어져 있기에 실제 운영체제의 보안 취약점이 크래커에게 공개되는 경우가 있을 수 있다는 것입니다. 하지만 반면에 전 세계적으로 분포된 Linux 개발 프로젝트에 참여한 개발자, 엔지니어, 테스터들이 문제점을 사전에 발견하여 지속적인 패치를 해준다는 장점이 있습니다. 실제 상용 UNIX 의 경우 보안적인 문제가 발생하더라도 이가 해당 보안 담당자에게 알려 지는 기간이 길기 때문에 패치가 나오기 전에 해킹을 당하는 경우가 많습니다. 하지만 LINUX 의 경우는 대부분의 해킹 사례가 이미 Linux 커뮤니티등에서 보안 이슈를 발표하고 1년이상 이후에 해당 취약점으로 패치가 안된 시스템을 공격하는 경우입니다. 이런 두가지 측면의 보안 이슈는 어느것이 좋고, 나쁨을 떠나 시스템 엔지니어의 보안에 대한 경각심과 시스템 보안 관리에 대한 노력의 문제라고 볼수 있습니다. 아래는 Linux 시스템을 설치 후 기본적인 보안 설정에 대해 설명한 것입니다. 초기 배포 환경에서는 여러 측면의 서비스를 대상으로 하기 때문에 해당 시스템의 서비스 성격과 다른 패키지와 보안 정책등이 부여가 되어져 있을 것입니다. 이는 실제 불필요한 시스템의 자원 낭비일 뿐만아니라 관리 하지 않는 보안적 헛점이 존재한다는 측면에서 보안적으로 취약점이 될수 있기에 설치 이후 서비스를 시작하기 전에 적절한 조치를 취해 줘야 하는 내용들입니다. 1.4.1 시스템 서비스 Daemon 관리 - 불필요한 서비스 Daemon 제거 Redhat 기반의 Linux 운영체제를 설치 하면 기본적으로 여러가지 서비스가 부팅 시

1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

1/32 페이지 서 진우([email protected])

1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치

1.4 운영체제 기본 보안 설정

Linux 운영체제는 Open Source 기반 운영체제입니다. Open Source 기반의 운영체제라는

조건이 실제 시스템 운영 측점에서 장점이 될수도 있고, 단점이 될 수도 있는데 대표적인

것이 바로 운영체제 보안이라 볼 수 있습니다.

운영체제의 Source code 가 공개되어져 있기에 실제 운영체제의 보안 취약점이 크래커에게

공개되는 경우가 있을 수 있다는 것입니다.

하지만 반면에 전 세계적으로 분포된 Linux 개발 프로젝트에 참여한 개발자, 엔지니어,

테스터들이 문제점을 사전에 발견하여 지속적인 패치를 해준다는 장점이 있습니다.

실제 상용 UNIX 의 경우 보안적인 문제가 발생하더라도 이가 해당 보안 담당자에게 알려

지는 기간이 길기 때문에 패치가 나오기 전에 해킹을 당하는 경우가 많습니다.

하지만 LINUX 의 경우는 대부분의 해킹 사례가 이미 Linux 커뮤니티등에서 보안 이슈를

발표하고 1년이상 이후에 해당 취약점으로 패치가 안된 시스템을 공격하는 경우입니다.

이런 두가지 측면의 보안 이슈는 어느것이 좋고, 나쁨을 떠나 시스템 엔지니어의 보안에

대한 경각심과 시스템 보안 관리에 대한 노력의 문제라고 볼수 있습니다.

아래는 Linux 시스템을 설치 후 기본적인 보안 설정에 대해 설명한 것입니다.

초기 배포 환경에서는 여러 측면의 서비스를 대상으로 하기 때문에 해당 시스템의 서비스

성격과 다른 패키지와 보안 정책등이 부여가 되어져 있을 것입니다. 이는 실제 불필요한

시스템의 자원 낭비일 뿐만아니라 관리 하지 않는 보안적 헛점이 존재한다는 측면에서

보안적으로 취약점이 될수 있기에 설치 이후 서비스를 시작하기 전에 적절한 조치를

취해 줘야 하는 내용들입니다.

1.4.1 시스템 서비스 Daemon 관리

- 불필요한 서비스 Daemon 제거

Redhat 기반의 Linux 운영체제를 설치 하면 기본적으로 여러가지 서비스가 부팅 시

Page 2: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

2/32 페이지 서 진우([email protected])

자동 시작이 되도록 설정이 되어져 있다. 하지만 대부분의 서비스들이 실제 서비스

대상과는 전혀 상관없는 서비스이다. 꼭 필요한 서비스이외의 나머지 서비스들은

아래와 같은 방법으로 부팅 시 자동 시작 리스트에서 제거 한다.

/sbin/chkconfig --del anacron

/sbin/chkconfig --del atd

/sbin/chkconfig --del autofs

/sbin/chkconfig --del echo

/sbin/chkconfig --del finger

/sbin/chkconfig --del gpm

/sbin/chkconfig --del nfs

/sbin/chkconfig --del nfslock

/sbin/chkconfig --del portmap

/sbin/chkconfig --del rlogin

/sbin/chkconfig --del rsh

/sbin/chkconfig --del rsync

/sbin/chkconfig --del lpd

/sbin/chkconfig --del xfs

- 필요한 서비스 추가

/sbin/chkconfig --add crond

/sbin/chkconfig --add network

/sbin/chkconfig --add sshd

/sbin/chkconfig --add syslog

/sbin/chkconfig --add named

/sbin/chkconfig --add proftpd

/sbin/chkconfig --add sendmail

/sbin/chkconfig --add nfs

/sbin/chkconfig --add portmap

/sbin/chkconfig --add rlogin

/sbin/chkconfig --add rsh

/sbin/chkconfig --add rsync

Page 3: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

3/32 페이지 서 진우([email protected])

부팅 시 자동 시작 서비스 Daemon 제어 방법으론 위 방식은 chkconfig 이외에

ntsysv 란 명령어를 이용하여 설정할수도 있다.

- 불필요한 Xinetd 서비스 제거

Xinetd 서비스 설정은 /etc/xinetd.d/ 안에 존재 한다. 이 설정 파일을 잘못 관리 하게 되면

원하지 않는 서비스를 허용하게 된다. 원천적으로 사용 하지 않는 서비스 설정에 대해서는

삭제 해 버리는 것이 좋다.

rm -f chargen

rm -f chargen-udp

rm -f daytime

rm -f daytime-udp

rm -f echo

rm -f echo-udp

rm -f finger

rm -f ntalk

rm -f rexec

rm -f rlogin

rm -f rsh

rm -f rsync

rm -f servers

rm -f services

rm -f sgi_fam

rm -f talk

rm -f telnet

rm -f time

rm -f time-udp

rm -f proftpd-inetd

1.4.2 시스템 계정 관리 및 운영체제 파일, Directory 권한 조정

Linux를 설치 하게 되면 기본적으로 많은 시스템 계정과 어플리케이션 계정이 존재 하게 된다.

Page 4: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

4/32 페이지 서 진우([email protected])

이는 이전의 Linux 버전에서 실제 서비스 Daemon의 대부분을 root 계정에서 관리를 하였는데

이런 취약한 서비스 Daemon을 이용하여 시스템의 root 권한을 외부에 허용하는 보안 상의

헛점이 많이 존재 하였다. 그 후 서비스 Daemon을 제어하는 시스템 계정을 별도로 생성하게

되었는데 이런 이유로 Linux를 기본적으로 설치 하면 많은 시스템 계정이 생성되게 된다.

하지만 사용하지 않는 서비스나 어플리케이션에 구동 되어지는 계정의 경우 불필요한 계정

관리 부담 및 보안 상에 위험 요소를 가지고 있게 된다. 이런 이유로 불필요한 계정과 그룹

정보를 초기 운영체제 설치 후에 반드시 지원 주도록 하다. 이런 기본 시스템 계정 삭제에

앞서 해당 설정 파일을 백업을 받고 삭제를 하길 바란다. 주요 백업 대상 파일은 /etc/passwd,

/etc/group, /etc/shadow 가 그에 해당한다.

- 불필요 계정 삭제

userdel adm

userdel lp

userdel sync

userdel shutdown

userdel halt

userdel news

userdel uucp

userdel operator

userdel games

userdel gopher

- 불필요 그룹 삭제

groupdel adm

groupdel lp

groupdel news

groupdel uucp

groupdel games

groupdel dip

Page 5: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

5/32 페이지 서 진우([email protected])

- 운영체제 기본 명령어 권한 조정 및 시스템 파일 보안 정책

기본 운영체제 설치 이 후 root setuid, setgid 권한의 명령어를 검색하여 불필요한 명령어의

퍼미션을 조정한다. 참고로 setuid, setgid 는 일반 유저가 해당 명령어를 실행할 때 root

권한으로 명령어가 실행되도록 하는 권한이다. 이는 해당 명령어를 통해 일반 유저가 root

관리자 권한을 얻게 되는 것으로 불필요한 경우에는 반드시 퍼미션을 조정해야 한다.

# find / -type f \( -perm -4000 -o -perm -2000 \)

chmod 700 /usr/bin/chage

chmod 700 /usr/bin/gpasswd

chmod 700 /usr/bin/wall

chmod 700 /usr/bin/chfn

chmod 700 /usr/bin/chsh

chmod 700 /usr/bin/newgrp

chmod 700 /usr/bin/write

chmod 700 /usr/bin/passwd

chmod 700 /usr/bin/at

chmod 700 /usr/bin/lockfile

chmod 700 /usr/bin/rcp

chmod 700 /usr/bin/rlogin

chmod 700 /usr/bin/rsh

chmod 700 /usr/bin/slocate

chmod 700 /usr/bin/crontab

chmod 700 /usr/libexec/openssh/ssh-keysign

chmod 700 /usr/sbin/ping6

chmod 700 /usr/sbin/traceroute6

chmod 700 /usr/sbin/usernetctl

chmod 700 /usr/sbin/userhelper

chmod 700 /usr/sbin/lockdev

chmod 700 /usr/sbin/userisdnctl

chmod 700 /usr/sbin/sendmail.sendmail

chmod 700 /usr/sbin/traceroute

chmod 700 /usr/sbin/utempter

chmod 700 /bin/ping

Page 6: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

6/32 페이지 서 진우([email protected])

chmod 700 /bin/mount

chmod 700 /bin/umount

chmod 700 /bin/su

chmod 700 /sbin/pam_timestamp_check

chmod 700 /sbin/pwdb_chkpwd

chmod 700 /sbin/unix_chkpwd

chomd 700 /usr/bin/gcc

chmod 700 /sbin/netreport

chmod 700 /usr/bin/sudo

아래는 setuid, setgid 권한의 명령어와 일반 관리자용 명령어 중 특정 일반 유저가 사용할

필요가 있는 경우 특정 그룹을 만들어 해당 그룹에 속한 유저만 사용 가능토록 지정하는

방법이다.

chmod 4750 /usr/bin/rcp

chmod 4750 /usr/bin/rsh

chmod 4750 /usr/bin/rlogin

chmod 4111 /usr/bin/sudo

chmod 2750 /usr/sbin/sendmail.sendmail

chmod 4750 /bin/su

chattr +i /etc/fstab

chmod 750 /bin/ps

chmod 750 /bin/netstat

chmod 750 /bin/dmesg

chmod 750 /bin/df

chmod 750 /usr/bin/w

chmod 750 /usr/bin/who

chmod 750 /usr/bin/last

chmod 750 /usr/bin/top

chmod 750 /usr/sbin/lsof

chmod 750 /usr/bin/gcc

Page 7: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

7/32 페이지 서 진우([email protected])

chgrp wheel /bin/ps

chgrp wheel /bin/netstat

chgrp wheel /bin/dmesg

chgrp wheel /bin/df

chgrp wheel /usr/bin/w

chgrp wheel /usr/bin/who

chgrp wheel /usr/bin/last

chgrp wheel /usr/bin/top

chgrp wheel /usr/sbin/lsof

chgrp whell /usr/bin/gcc

chgrp wheel /usr/bin/rcp

chgrp wheel /usr/bin/rsh

chgrp wheel /usr/bin/rlogin

# vi /etc/group

===============================================================.

wheel:x:10:root,clunix,alang.

===============================================================

- 시스템 Directory 권한 조정

chmod 711 /

chmod 711 /home

chmod 711 /var

chmod 711 /var/log

chmod 711 /etc

chmod 700 /root

1.4.3 운영체제 기본 서비스 보안 설정

- 일반 Shell 사용자 보안 설정

시스템에 여러 개의 접속 계정이 있을 경우 사용자 계정에 따른 적절한 보안 정책이 주어

져야 한다. 즉 사용자 별 시스템 자원 사용 제한 정책이나, 사용자의 특정 작업을 감시하는

형태의 보안이 필요하게 된다.

Page 8: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

8/32 페이지 서 진우([email protected])

사용자별 자원의 할당 정책은 주로 사용자 그룹을 이용하여 제한을 두는 것이 관리상 편리

하다. 자원의 제한 설정은 /etc/security/limits.conf 설정 파일에서 제어할 수 있다.

# vi /etc/security/limits.conf

-------------------------------------------------------------------

@student hard nproc 20

@admin soft nproc 20

@admin hard nproc 50

ftp hard nproc 3

@student - maxlogins 4

alang - maxlogins 2

-------------------------------------------------------------------

설정의 경우 student 란 그룹의 속해진 유저들은 이 시스템에서 최대 20개의 프로세스

사용할 수 있고. 최대 4개의 터미널 접속이 가능하도록 제한되어진다.

limits.conf 의 설정 방식은 아래와 같다.

<domain> <type> <item> <value>

<domain>은 시스템 계정이나 그룹에 해당되며 공백일 경우에는 와일드카드 문자인 *

이 적용되어진다. 그룹의 경우에는 그룹명 앞에 '@' 를 붙여 사용할 수 있다.

<type>의 경우는 hard 와 soft 로 나누어지며 hard 의 경우는 hard limit 에 해당하고

soft 는 soft limit 에 해당하는 값이다. hard, soft limit 는 시스템 명령인 ulimit 란

명령으로 확인이 가능하다.

hard limit 확인 -> # ulimit -Ha

soft limit 확인 -> # ulimit -Sa

<item>의 경우는 실제 세부적인 시스템 자원에 해당된다. 여기에는 여러가지 해당 값으로

Page 9: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

9/32 페이지 서 진우([email protected])

나눌 수 있다. 대표적인 항목으로는 다음과 같다.

core - limits the core file size (KB)

data - max data size (KB)

fsize - maximum filesize (KB)

memlock - max locked-in-memory address space (KB)

nofile - max number of open files

rss - max resident set size (KB)

stack - max stack size (KB)

cpu - max CPU time (MIN)

nproc - max number of processes

as - address space limit

maxlogins - max number of logins for this user

priority - the priority to run user process with

locks - max number of file locks the user can hold

<value>는 각 자원의 제한 값이다.

이밖에 사용자의 주요 작업 내역에 대해서는 아래의 방식으로 관리가 가능하다.

물론 이런 방식이 정상적으로 허용될지에 대해서는 각 사이트마다 다를 것이다.

하지만 여러 명의 사용자가 존재하고 모두의 정상적인 시스템 사용을 위해서는 관리자의

막강한 관리 권한이 주어져야 하며, 권한을 가진 관리자에게는 시스템 관리에 따른

윤리성에 대한 자각이 갖추어져야 한다. 아래 방식은 실제 사용자의 주요 작업 history

를 관리자가 쉽게 파악할 수 있도록 하는 방법이다. 관리자의 경우는 실제 시스템적

관리 권한에 이미 일반 사용자의 작업 history를 볼 수 있는 권한이 주어진다.

하지만 운영 정책에 의해 제한 되어지는 환경도 많을 것이다. 아래 방법은 시스템상에서

적절한 권한을 위임 받은 상태에서 보다 효율적인 관리를 위해서 사용될 수 있는 방법일

것이다.

- 일반 shell 사용자 작업 내용 감시 하기

/etc/profile 파일의 제일 밑 부분에 아래 내용 추가

===============================================================

Page 10: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

10/32 페이지 서 진우([email protected])

if [ $LOGNAME != "root" ]

then

HISTFILE=/var/log/user_history

TMOUT=200

echo -n "

===============================================================

userhistory 로그인 ID: $LOGNAME 접속시간 : `/bin/date`

===============================================================

" >> /var/log/user_history

fi

===============================================================

/root/.bashrc 파일 밑 부분에 다음 라인 추가

===============================================================

HISTFILE=/root/.bash_history

TMOUT=-1

===============================================================

그런후 /var/log 밑에 user_history 란 파일을 생성합니다.

# touch /var/log/user_history

마지막으로 /var/log/user_history 파일의 permission을 662 으로 해줍니다.

# chmod 662 /var/log/user_history

위와 같은 설정이 완료되면 일반 계정에서 로그인을 했을 경우 사용자 계정의 홈Directory

밑에 생성되어져야 할 작업 history 가 /var/log/user_history 밑에 아래와 같이 생성이

될것이다.

Page 11: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

11/32 페이지 서 진우([email protected])

# cat /var/log/user_history

===============================================================

userhistory 로그인 ID: alang 접속시간 : Mon Apr 11 16:34:42 KST 2005

===============================================================

ls

ls

ps ax

cat .bash_history

참고 : 위 설정에서 TIMEOUT 설정은 사용자 계정이 접속 한 후 아무런 작업없이 200초를

유휴 상태로 있을 경우 자동 logoff 시키는 명령이다. limits.conf 등에서 사용자 계정의

터미널 최대 접속 수를 제한했을 경우 실제 시스템을 사용하지 않는 상태에서 접속만하고

있을 경우 다른 사용자들이 시스템 접속 제한에 걸려 접속을 하지 못하는 것을 방지하기

위한 설정이다. 만일 접속 사용자의 편의를 최대한 보장한다고 한다면, limits.conf 설정

의 maxlogin과 위 설정의 TIMEOUT 설정을 제거 하도록 한다.

이제 위의 사용자 history 내역을 관리자에게 자동 메일을 보내주는 스크립트를 사용하

여 매일 편리하게 사용자 관련 보안을 점검하면 된다.

# vi cmdchk

--------------------------------------------------------------------------------

#!/bin/sh

date=`date +%Y%m%d`

[email protected]

if [ -s /var/log/user_history ]

then

mail -s "$date `hostname` user_history check" [email protected] < /var/log/user_history

echo > /var/log/user_history

fi

--------------------------------------------------------------------------------

Page 12: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

12/32 페이지 서 진우([email protected])

- Xinetd 서버스 보안 정책

시스템 기본 접속 단계에 해당하는 telnet, ssh, ftp 등의 서비스는xinetd 란 수퍼 Daemon

상에서 관리 되어 진다. 이는 Linux 기본 정책일뿐 반드시 위 서비스가 xinetd Daemon 상에서

관리되어야 하는 것은 아니다. xinetd Daemon의 자세한 사용법에 대해서는 별도의 서적이나

인터넷 상의 정보를 참고 하길 바란다. 여기서는 xinetd 상에서 구동되는 서비스의 기본 보안

설정에 대해서만 다루도록 한다.

xinetd Daemon으로 구동 되어 지는 서비스들은 /etc/service 란 설정 파일에서 확인할 수 있다.

그리고 실제 서비스 적용 사항들은 /etc/xinetd.d 란 Directory에서 확인이 가능하다.

xinetd 설정 형식은 다음과 같다.

# cat /etc/xinetd.d/rsh

-----------------------------------------------------------------------------

service shell

{

disable = yes

socket_type = stream

wait = no

user = root

log_on_success += USERID

log_on_failure += USERID

server = /usr/sbin/in.rshd

}

------------------------------------------------------------------------------

실제 위 설정에서 'disable' 설정에 'yes' 가 되어 있는 경우 서비스를 off 시켜 두겠

다는 의미이다. 실제 사용을 하지 않는 서비스의 경우에서 설정 파일을 제거하는 것이

안정할 것이다. 임시적으로 사용을 중단하는 것이라면 위 설정과 같이 disable = yes

상태로 두는 것이 좋다.

이런 형태의 xinetd Daemon으로 관리하는 서비스의 경우 TCP Wrapper 란 프로그램으로

서비스

에 대한 접근 권한을 제어 할수 있다. 이는 iptables 와 같은 netfilter 기반의 보안방식

에 비해 가볍고 효율적인 보안 관리가 가능하다.

Page 13: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

13/32 페이지 서 진우([email protected])

아래는 tcp wrapper 설정 방법이다.

# vi /etc/hosts.deny

===============================================================

sshd : ALL : twist ( /root/bin/hostchk Y Y %a %c %d %h %n %p %s %u ) &

in.proftpd : ALL : twist ( /root/bin/hostchk Y Y %a %c %d %h %n %p %s %u ) &

===============================================================

# vi /etc/hosts.allow

===============================================================

sshd : localhost 127.0.0.1 211.241.202. 192.168.1.

in.proftpd : localhost 127.0.0.1 211.241.202. 192.168.1.

===============================================================

tcp wrapper 설정은 /etc/hosts.deny 와 /etc/hosts.allow 두가지 설정으로 나누어 진다.

hosts.deny 는 서비스 거부 설정이고 hosts.allow 는 서비스 허가 설정이다.

순서로 보면 /etc/hosts.deny 설정 파일에서 서비스 접근을 거부 시킬 서비스와 그 영역

을 설정한다.

위 설정에서는 sshd, proftpd 란 서비스에 대해 모든 곳에서의 접속을 거부한다는 의미다.

twist 설정은 실제 거부되는 서비스에 접근 시도가 있을 경우 뒤에 설정된 명령을 실행시키는

설정이다.

그런 후 접속을 허가할 사이트에 대해서 hosts.allow 파일에 허가 설정을 하도록 한다.

서비스 설정 방식은 아래와 같다.

Page 14: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

14/32 페이지 서 진우([email protected])

<service>:<address>:<option>

<service>는 xinetd Daemon 상에서 구동되어지는 서비스 명이다.

<address>는 접속 사이트의 IP 주소 및 Subnet 영역 등이 포함된다.

'ALL' 이란 설정으로 모든 영역을 나타낼 수 있다.

<option>은 twist 와 같이 접근 제한, 혹은 접근 허가 이후 특정 작업을 실행할 수 있다.

위 설정은 hosts.allow 에서 허가하지 않는 사이트에서 접근할때 접근을 거부 시키고

/root/bin/hostchk 란 명령어를 실행하라는 의미이다.

hostchk 란 명령어는 접속 사이트 정보를 관리자에게 메일로 보내주는 관리용 스크립터

명령이다.

# vi /root/bin/hostchk

--------------------------------------------------------------------------------

#!/bin/sh

################################ 변수정의부문

# 메일 수신자

[email protected]

# 화면출력 여부, 메일전송 여부

dsp=$1; msg=$2

# 접속자 정보 등

a=$3; c=$4; d=$5; h=$6; n=$7; p=$8; s=$9; u=$10

# 현재 시간

time=`date`

# 접속시도자 소속 서버의 finger 정보

finger=`/usr/bin/finger -l @$h 2> /dev/null`

Page 15: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

15/32 페이지 서 진우([email protected])

################################ 화면 출력부문

if [ $dsp = Y ]

then

/bin/echo -n "

===================================

접속이 허용되지 않습니다.

===================================

Access Time : $time

Client host address : $a

Client information : $c

Client host name(or IP) : $h

Client host name : $n

Client user name : $u

"

fi

################################ 메일 송신부문

if [ $msg = Y ]

then

/bin/echo -n "

===============================

접속 거부자 상세정보

===============================

Access Time : $time

Access client host address : $a

Access client information : $c

The daemon process name : $d

Page 16: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

16/32 페이지 서 진우([email protected])

Access client host name(or IP) : $h

Access client host name : $n

The daemon process id : $p

Server information : $s

Access client user name : $u

--------------------------------------

Access client finger information

--------------------------------------

$finger

------------------------------------------------

" | \

/bin/mail -s "tcp_wrapper report [$d]" $mailto

fi

------------------------------------------------------------------------------------

허가 되지 않은 영역에서 접속을 하게 되면 위 관리 스크립터에 지정된 관리자 메일 주소

로 아래와 같은 Message 가 발송이 되어진다.

===============================

접속거부자 상세정보

===============================

Access Time : Mon Apr 11 17:18:25 KST 2005

Access client host address : 192.168.133.1

Access client information : arh01.clunix.org

The daemon process name : sshd

Access client host name(or IP) : arh01.clunix.org

Access client host name : arh01.clunix.org

The daemon process id : 4154

Server information : [email protected]

Access client user name : Y0

Page 17: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

17/32 페이지 서 진우([email protected])

--------------------------------------

Access client finger information

--------------------------------------

------------------------------------------------

보안과 사용자 편리성은 상극적인 관계 상에 존재한다. 사용자의 편의 만을 생각하면 실제

아무런 보안 설정이 되어져 있지 않는 것이 좋을 것이다. 오랜 시간 안정적인 시스템 환경

유지를 위해서라면 철저한 시스템 보안 정책 위주의 보안이 필요할 것이다. 하지만 이런

보안 환경에서는 사용자의 불편함이 클 수 밖에 없다. 이 두 가지 관계 속에 해당 사이트의

특성을 최대한 고려하여 관리자는 보안 정책을 적용해야 할 것이다.

1.4.4 기본 보안 프로그램 설치 및 관리

- Tripwire 설치 및 관리

Tripwire 은 원래 Linux가 아닌 유닉스 플랫폼에서 설계되어 왔으나 현재 Linux에서

대표적으로 사용되는 파일 무결성 검사 도구이다.

Tripwire는 시스템 파일 등의 변조 및 추가 등을 검사함으로써..해킹의도를 파악할 수 있는

보안 도구 입니다.

Tripwrie 설치 전 몇 가지 알아 두어야 할 점이 있다.

검사도구는 시스템 설치 후에 바로 설치해야 의미가 있다.이미 해킹 당한 상태에서 설치 해

보아야 검사도구엔 발견 되지 않는다.

초기에 아주 깨끗한 상태에서 시스템 파일 정보들을 DB file로 만들어 놓고 앞으로 변화

되는 상황을 지켜 보아야 한다.

그리고 시스템 정보가 저장될 DB file 이 다른 사람에게 접근을 허용하면 안 된다.

이 두 가지만 철저하게 지키면 아주 유용한 보안 도구로 사용이 가능하다.

이제 설치에 들어가 보도록 하자. 설치는 RPM 과 Source 두 가지 방법이 있다.

먼저 Source 설치 방법에 대해 알아보자.

Page 18: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

18/32 페이지 서 진우([email protected])

tripwire 소스는 다음 사이트에서 다운 받을 수 있다.

http://www.tripwire.org

특정 Directory에 소스를 다운 받아 압축을 푼다.

# tar xzvf tripwire-2.3-47.bin.tar.gz

# cd tripwire-2.3

# ./install.sh

------------------------------------------------------------------------------------

Installer program for:

Tripwire(R) 2.3 Open Source for LINUX

Copyright (C) 1998-2000 Tripwire (R) Security Systems, Inc. Tripwire (R)

is a registered trademark of the Purdue Research Foundation and is

licensed exclusively to Tripwire (R) Security Systems, Inc.

LICENSE AGREEMENT for Tripwire(R) 2.3 Open Source for LINUX

Please read the following license agreement. You must accept the

agreement to continue installing Tripwire.

Press ENTER to view the License Agreement. <--- [ ENTER ]

.

.

consider it more useful to permit linking proprietary applications with the

library. If this is what you want to do, use the GNU Library General

Public License instead of this License.

Please type "accept" to indicate your acceptance of this

license agreement. [do not accept] <--- [ accept ]

.

Page 19: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

19/32 페이지 서 진우([email protected])

.

TWBIN: /usr/sbin

TWMAN: /usr/man

TWPOLICY: /etc/tripwire

TWREPORT: /var/lib/tripwire/report

TWDB: /var/lib/tripwire

TWSITEKEYDIR: /etc/tripwire

TWLOCALKEYDIR: /etc/tripwire

CLOBBER is false.

Continue with installation? [y/n] <--- [ y ]

Creating key files...

(When selecting a passphrase, keep in mind that good passphrases typically

have upper and lower case letters, digits and punctuation marks, and are

at least 8 characters in length.)

Enter the site keyfile passphrase: <--- [ password ]

Verify the site keyfile passphrase: <--- [ password ]

(When selecting a passphrase, keep in mind that good passphrases typically

have upper and lower case letters, digits and punctuation marks, and are

at least 8 characters in length.)

Enter the local keyfile passphrase: <--- [ password ]

Verify the site keyfile passphrase: <--- [ password ]

.

.

----------------------------------------------

Generating Tripwire configuration file...

----------------------------------------------

Page 20: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

20/32 페이지 서 진우([email protected])

Creating signed configuration file...

Please enter your site passphrase: <--- [ password ]

.

----------------------------------------------

Customizing default policy file...

----------------------------------------------

Creating signed policy file...

Please enter your site passphrase: <--- [ password ]

----------------------------------------------

The installation succeeded.

Please refer to /usr/doc/tripwire/Release_Notes

for release information and to the printed user documentation

for further instructions on using Tripwire 2.3 Open Source for LINUX.

이로써 tripwire 의 설치가 완료되었다.

설치가 완료된 시점에서 일단 Tripwire 의 초기 DB 데이터를 생성하도록 한다.

Tripwire 의 초기 DB 데이터란 현 시스템의 운영체제의 파일들의 무결성 점검 결과를

저장한 DB 파일을 초기화 시킨다는 의미이다. 즉 깨끗한 시스템 파일 초기 상태의 기준

을 세운다는 의미로 보면 된다.

만일 이 초기화 작업을 이미 해킹을 당해 백도어가 설치된 상태에서 초기화를 시킨다고

하면 이런 Back door 까지도 무결 파일의 기준으로 인식하게 된다.

그렇기 때문에 Tripwire 같은 무 결성 프로그램은 반드시 OS 설치 후 정식 서비스를 시작하기

전에 설치를 해 두는 것이 좋을 것이다.

# tripwire --init

Please enter your local passphrase: <--- [ password ]

이제 tripwire로 파일 시스템의 무 결성을 체크 하면 된다.

# tripwire --check

Page 21: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

21/32 페이지 서 진우([email protected])

Redhat 배포 판의 경우 RPM 방식으로 배포를 하기 때문에 이 패키지 사용을 권장한다.

아래는 간단한 RPM 방식의 설치 및 기본 설정 방법에 대해 소개한다.

Redhat Linux 9 배포 판 CD3 에 tripwire-2.3.1-17 버전의 패키지가 존재한다.

해당 RPM을 설치 한다.

# rpm -Uvh tripwire-2.3.1-17.i386.rpm

설치 정보는 다음과 같다.

ROOT =/usr/sbin

POLFILE =/etc/tripwire/tw.pol

DBFILE =/var/lib/tripwire/$(HOSTNAME).twd

REPORTFILE =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr

SITEKEYFILE =/etc/tripwire/site.key

LOCALKEYFILE =/etc/tripwire/$(HOSTNAME)-local.key

이제 위의 소스 방식의 설치 단계에 나오는 site.key 생성 및 로컬 인증키 생성 등의 과정에

해당하는 기본 보안 설정 스크립터인 twinstall.sh 를 실행한다.

twinstall.sh 실행 전에 /etc/tripwire/twpol.txt 에서 무 결성 체크 대상 설정 변경 후에도

실행하도록 한다.

초기 twpol.txt 에 정의된 보안 정책은 기본 운영체제에 맞는 보안체제기 때문에 바로 적용

하기엔 너무 많은 체크 대상을 포함하게 된다. 그렇기 때문에 초기에는 우선 초기화 명령을

실행해서 출력되는 에러 내용을 파악하여 현 시스템에 맞는 체크 대상을 만들도록 한다.

# tripwire --init 2> error

# cat error

------------------------------------------------------------------------------------.

.

### Filename: /bin/ksh

### 그런 파일이나 Directory가 없음

### Continuing...

Page 22: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

22/32 페이지 서 진우([email protected])

### Warning: File system error.

### Filename: /root/.esd_auth

### 그런 파일이나 Directory가 없음

### Continuing...

### Warning: File system error.

### Filename: /root/.gnome_private

### 그런 파일이나 Directory가 없음

### Continuing...

### Warning: File system error.

### Filename: /root/.gnome-desktop

### 그런 파일이나 Directory가 없음

### Continuing...

### Warning: File system error.

### Filename: /root/.gnome

### 그런 파일이나 Directory가 없음

------------------------------------------------------------------------------------

위는 기본 정책에는 들어있는 체크 대상이지만 현 시스템에는 존재하지 않는 대상들이다.

이 부분들을 /etc/tripwire/twpol.txt 에서 제거하고 다시 /etc/tripwire/twinstall.sh 를

실행한다.

# /etc/tripwire/twinstall.sh

체크 대상 보안 정책 DB 파일을 재생성 한다.

# twadmin --create-polfile twpol.txt

새로 생성된 체크 대상 보안 정책으로 초기 체크 대상 DB 파일을 초기화 한다.

# tripwire --init

이제 파일 시스템의 무결성을 체크 한다.

# tripwire --check

Page 23: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

23/32 페이지 서 진우([email protected])

체크한 결과는 터미널 상에 출력되고, /var/lib/tripwire/report 에 twr확장 DB 파일로

생성이 된다.

twr 결과 리포트를 다시 확인 하고 싶을 때는 아래 방식을 이용하면 된다.

# twprint -m r --twrfile /var/lib/tripwire/report/arhdev-20050415-102800.twr

그럼 아래와 같은 결과가 출력된다.

------------------------------------------------------------------------------------

Note: Report is not encrypted.

Tripwire(R) 2.3.0 Integrity Check Report

Report generated by: root

Report created on: 2005 04 15 () 10 28 00

Database last updated on: Never

===============================================================

Report Summary:

===============================================================

Host name: arhdev

Host IP address: 192.168.133.9

Host ID: None

Policy file used: /etc/tripwire/tw.pol

Configuration file used: /etc/tripwire/tw.cfg

Database file used: /var/lib/tripwire/arhdev.twd

Command line used: tripwire --check

===============================================================

Rule Summary:

===============================================================

-------------------------------------------------------------------------------

Section: Unix File System

-------------------------------------------------------------------------------

Rule Name Severity Level Added Removed Modified

--------- -------------- ----- ------- --------

Invariant Directories 66 0 0 0

Temporary directories 33 0 0 0

Tripwire Data Files 100 0 0 0

Critical devices 100 0 0 0

Page 24: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

24/32 페이지 서 진우([email protected])

User binaries 66 0 0 0

Tripwire Binaries 100 0 0 0

Libraries 66 0 0 0

Operating System Utilities 100 0 0 0

Critical system boot files 100 0 0 0

File System and Disk Administraton Programs

100 0 0 0

Kernel Administration Programs 100 0 0 0

Networking Programs 100 0 0 0

System Administration Programs 100 0 0 0

Hardware and Device Control Programs

100 0 0 0

System Information Programs 100 0 0 0

Application Information Programs

100 0 0 0

Shell Related Programs 100 0 0 0

Critical Utility Sym-Links 100 0 0 0

Shell Binaries 100 0 0 0

Critical configuration files 100 0 0 0

System boot changes 100 0 0 0

OS executables and libraries 100 0 0 0

Security Control 100 0 0 0

Login Scripts 100 0 0 0

Root config files 100 0 0 0

------------------------------------------------------------------------------------

이제 테스트를 해보도록 하자

/bin Directory 밑에 test 란 임의의 파일을 하나 생성하고, /bin 밑의 명령어의 permission을

변경해 보도록 하자.

# echo > /bin/test

# chmod 700 /bin/vi

그런 후 무결성 체크를 재 시도 해보자

# tripwire --check

# twprint -m r --twrfile /var/lib/tripwire/report/arhdev-20050415-104007.twr

------------------------------------------------------------------------------------ ===============================================================

Rule Summary:

Page 25: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

25/32 페이지 서 진우([email protected])

===============================================================

-------------------------------------------------------------------------------

Section: Unix File System

-------------------------------------------------------------------------------

Rule Name Severity Level Added Removed Modified

--------- -------------- ----- ------- --------

Invariant Directories 66 0 0 0

Temporary directories 33 0 0 0

Tripwire Data Files 100 0 0 0

Critical devices 100 0 0 0

User binaries 66 0 0 0

Tripwire Binaries 100 0 0 0

Libraries 66 0 0 0

* Operating System Utilities 100 0 0 1

Critical system boot files 100 0 0 0

File System and Disk Administraton Programs

100 0 0 0

Kernel Administration Programs 100 0 0 0

Networking Programs 100 0 0 0

System Administration Programs 100 0 0 0

Hardware and Device Control Programs

100 0 0 0

System Information Programs 100 0 0 0

Application Information Programs

100 0 0 0

Shell Related Programs 100 0 0 0

Critical Utility Sym-Links 100 0 0 0

Shell Binaries 100 0 0 0

Critical configuration files 100 0 0 0

System boot changes 100 0 0 0

* OS executables and libraries 100 1 0 1

Security Control 100 0 0 0

Login Scripts 100 0 0 0

* Root config files 100 0 0 2

.

.

-------------------------------------------------------------------------------

Rule Name: OS executables and libraries (/bin)

Severity Level: 100

-------------------------------------------------------------------------------

Added:

"/bin/alang"

Modified:

Page 26: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

26/32 페이지 서 진우([email protected])

"/bin"

.

.

-------------------------------------------------------------------------------

Rule Name: Operating System Utilities (/bin/vi)

Severity Level: 100

-------------------------------------------------------------------------------

Modified:

"/bin/vi"

.

-----------------------------------------------------------------------------------

위와 같이 초기화 DB 에서 변경된 사항들을 확인 할 수 있다.

시스템을 관리 하면서 추가로 패키지를 설치하거나 관리 목적으로 설정 파일등을 변경했을때

매번 결과 리포트에 변경 사항이 적용되어 출력이 될것이다. 그렇기에 변경된 내용을 새로

업데이트 하여 초기 DB 를 갱신해야 할 때가 있다. 이때는 아래의 명령행을 이용한다.

# tripwire --update --twrfile /var/lib/tripwire/report/arhdev-20050415-104007.twr

그럼 결과 리포트 중 변동 내역에 대한 자세한 정보를 출력해 주고 이를 확인 후 관리작업

상의 변동 사항이라고 하면 site.key 의 인증 암호를 입력하여 업데이트를 시키도록 한다.

이로써 Tripwire 를 이용한 파일 시스템 무 결성 체크에 대한 설명을 마치도록 한다.

- fcheck 설치 및 관리

fcheck 는 perl 기반의 파일 무결성관리 프로그램으로 Tripwire 에 비해 가볍고 간단하면서

Tripwire 와 유사한 역할을 충분히 해준다.

먼저 프로그램을 다운 받도록 하자.

http://www.geocities.com/fcheck2000/

가면 최신 프로그램이 있을 것이다. 다운을 받고 /usr/local 및에 둔다.

압축을 풀고..fcheck,fcheck.cfg 파일의 설정 값을 몇 개 수정하자.

Page 27: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

27/32 페이지 서 진우([email protected])

# tar xzvf FCheck_2.07.59.tar.gz

# cd fcheck

# vi fcheck

-------------------------------------------------------------------

.

.

###############################################################

##############

# #

# User modifiable variable definitions: #

# #

###############################################################

##############

# This should be passed through the command line, but hard coding still works

$config="/usr/local/fcheck/fcheck.cfg";

----------------------------------------- 이부분을 시스템 환경에 맞게 수정

-------------------------------------------------------------------

# vi fcheck.cfg

-------------------------------------------------------------------

Directory = /etc/

Directory = /bin/

Directory = /usr/bin/

Directory = /sbin/

Directory = /usr/sbin/

Directory = /usr/local/bin/

Directory = /usr/local/sbin/

Directory = /lib/

Directory = /usr/lib/

Directory = /usr/local/lib/

#

# Directory 설정은 fcheck 가 체크할 파일들이 들어 있는 Directory로 시스템에

Page 28: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

28/32 페이지 서 진우([email protected])

# 중요한 명령어나 설정파일등이 있는 곳을 정해 주면 된다.

#

Exclusion = /etc/passwd

Exclusion = /etc/shadow

#

# Exclusion 설정은 Directory 설정에서 정한 Directory중 자주 변경이 되는 파일

# 이 있어서 체크때마다 걸리므로 체크 생략을 요하는 파일을 정해 주면 된다.

# 호스팅 업체나 기타 자주 사용자를 추가하는 서버라면 위와 같이 해주면 된다.

#

DataBase = /usr/local/fcheck/data/data.dbf

#

# DataBase 설정은 Linux 파일 정보를 DB 파일로 저장해서 다음 체크시 비교

# 분석할때 사용되어진다.

#

TimeZone = GMT-9

#

# 한국 시간을 적용한다. GMT-9

#

#File = /usr/local/admtools/logs/sol.dbf

-------------------------------------------------------------------------

File 설정은 필요 없으니 주석 처리 해준다.

기타 여러 설정값이 있으나 크게 작동하는데 영향을 주지 않는다.기본값을 적용

한다.

이와 같이 적용후 /usr/local/fcheck/data Directory를 만들어 준다.

Page 29: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

29/32 페이지 서 진우([email protected])

# mkdir /usr/local/fcheck/data

# /usr/local/fcheck/fcheck -ac

이와 같이 fcheck -ac 로 파일 무결성 체크를 시작한다. 그럼 data Directory 안

에 data.dbf 파일이 생성되어 진다.

이제 Directory 설정에 해당하는 Directory 안에다가 파일을 하나 생성하고 재대

로 점검을 하는지 테스트를 하여 보자..

# touch /etc/test

# /usr/local/fcheck/fcheck -a

그럼 아마 아래와 같은 결과를 출력할것이다.

PROGRESS: validating integrity of /etc/

STATUS:

ADDITION: [zzang911.net] /etc/test

Inode Permissons Size Created On

19508 -rw-r--r-- 0 Sep 19 20:13 2001

자 이제 이 명령어를 이용하여 주기적으로 시스템 파일 무결성을 체크하고 관리

자에게 통보하는 프로그램을 만들어 보도록 하자.

# vi /root/bin/fcheck.sh

---------------------------------------------------------------------------

#!/bin/sh

[email protected]

CHECK=`/usr/local/fcheck/fcheck -a | grep Inode`

HOSTNAME=`hostname`

if [ -n "$CHECK" ]

then

/usr/local/fcheck/fcheck -a > fcheck_result

mail -s "$HOSTNAME File 무결성 체크 결과" $ADM_MAIL < fcheck_result

Page 30: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

30/32 페이지 서 진우([email protected])

rm -f fcheck_result

fi

----------------------------------------------------------------------------

간단한 이정도 스크립터로 보다 효율적인 관리가 가능해 질것이다.

이제 cron 에 등록시켜 놓고..매일 파일 무결성 체크를 간단히 메일로 받아서 관리

할수 있게 된다. 만일 변화된 파일이 정당한 변화라면..

# /usr/local/fcheck/fcheck -ac

로 DBfile 를 업데이트 시켜 줘야 한다. 아님..계속 메일이 날아 오게 된다.

이로써 시스템 설치후 점검해야 할 보안 설정에 대해서 마치겠다. 시스템 보안은

초기의 보안 설정이 아주 큰 부분을 차지 하고 있다. 하지만..지속적은 감시와

관리역시 초기 보안 상태를 유지하는 가장 중요한 작업이라고도 할수 있다.

- Service Port Scan 확인

기본적인 OS 설정 및 보안 설정이 완료되면 최종적으로 현재 서비스가 이루어

지는 TCP/IP Port 에 대해 시스템 초기 상태에서 알아 두어야 한다.

이후 이때 파악 되지 않는 서비스 포트가 열려 있을 경우 보안에 의심을 해보

아야 할 것이다.

Port Scan 도구로는 가장 많이 사용하는것이 nmap,nc,netstat,lsof 등 이다.

사용법은 다음과 같다.

nmap,nc,netstat 등을 이용해서 시스템의 열린 포트를 점검한다.

# nmap localhost -p 1-65535

# nc -w 3 -v -z localhost 1-65535

# netstat -ant | grep LISTEN

Page 31: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

31/32 페이지 서 진우([email protected])

21/tcp open ftp

22/tcp open ssh

23/tcp open telnet

25/tcp open smtp

53/tcp open domain

80/tcp open http

3306/tcp open mysql

불필요한 서비스 포트가 열려 있는 경우엔 반드시 해당 Daemon이나 서비스를 off 시켜

크래킹에 이용되지 않도록 조치한다.

1.4.5 기타 추가 설정

이후 사이트 서비스 성격이나 시스템 관리자 취향에 맞게 추가 설정을 해 주도록 한다.

- Time 설정

# rdate -s time.bora.net

- command alias 설정

# vi .bash_profile

------------------------------------------------------------------------------

alias vf='vi /etc/proftpd/proftpd.conf'

alias rf='/etc/rc.d/init.d/proftpd restart'

alias rx='/etc/rc.d/init.d/xinetd restart'

alias vh='vi /usr/local/apache/conf/httpd.conf +'

alias re='/usr/local/apache/bin/apachectl restart'

alias rn='/etc/rc.d/init.d/named restart'

alias rs='/etc/rc.d/init.d/sendmail restart'

------------------------------------------------------------------------------

Page 32: 1. 실무 환경을 고려한 엔터프라이즈 Linux 운영체제 설치syszone.co.kr/PDF/enterprise-linux-1-2.pdfchmod 700 /sbin/unix_chkpwd chomd 700 /usr/bin/gcc chmod 700 /sbin/netreport

* 실무 관리자를 위한 Linux Enterprise Server ( Linux Operating System )

32/32 페이지 서 진우([email protected])

- System Login Information 설정

# vi /etc/issue ( 콘솔 접속 로그인 화면 )

# vi /etc/issue.net ( Telnet 접속 로그인 화면 )

# vi /etc/motd ( ssh, rsh 등의 원격 접속 로그인 화면 )

- 시스템 시작 시 자동 실행 작업

시스템이 Rebooting 될 때 자동으로 실행 시켜야 하는 프로그램이나 명령어가 있을 경우

/etc/rc.d/rc.local 설정파일 마지막에 실행 명령을 적으면 된다.

특정 계정 로그인 시 자동으로 실행해야 하는 작업이 있을 경우는 해당 계정의 홈 폴더

밑에 있는 .bash_profile 혹은 .bashrc 파일 하단에 해당 작업을 적어 주면 된다.