RedHat Linux >> Security for Linux
|
[목차] |
제4장 리눅스 인터넷 보안
1. Red Hat / Centos Install Denyhosts To Block SSH Attacks / Hacking 1. denyhosts 설치 RPM과 Source 설치가 있는데 여기에선 RPM 으로 간단히 설치해 보자. python 버전을 확인해보자. [root@www down]# rpm -qa | grep python ... python-2.4.3-46.el5_8.2 ... denyhosts는 python 으로 동작하기 때문에 필히 python을 설치해야 한다. 설치되지 않았다면, 아래와 같이 설치한다. [root@www down]# yum install python 아래 사이트에서 자신에게 맞는 버전을 다운로드 한다. [root@www down]# wget http://jaist.dl.sourceforge.net/sourceforge/denyhosts/DenyHosts-2.6-python2.4.noarch.rpm [root@www down]# rpm -Uvh DenyHosts-2.6-python2.4.noarch.rpm [root@www down]# cd /usr/share/denyhosts/ [root@www denyhosts]# ls CHANGELOG.txt README.txt denyhosts.cfg-dist scripts LICENSE.txt daemon-control-dist plugins setup.py [root@www denyhosts]# cp denyhosts.cfg-dist denyhosts.cfg [root@www denyhosts]# cp daemon-control-dist /usr/local/bin/daemon-control [root@www denyhosts]# chown root /usr/local/bin/daemon-control [root@www denyhosts]# chmod 700 /usr/local/bin/daemon-control [root@www denyhosts]# cd /etc/init.d/ [root@www init.d]# ln -s /usr/local/bin/daemon-control denyhosts [root@www init.d]# chkconfig denyhosts --add [root@www init.d]# cd /etc 시스템로그 형태를 선택한다. [root@www etc]# vi denyhosts.cfg ... 생략 ... ####################################################################### # # DAEMON_LOG_TIME_FORMAT: when DenyHosts is run in daemon mode # (--daemon flag) this specifies the timestamp format of # the DAEMON_LOG messages (default is the ISO8061 format: # ie. 2005-07-22 10:38:01,745) # # for possible values for this parameter refer to: man strftime # # Jan 1 13:05:59 DAEMON_LOG_TIME_FORMAT = %b %d %H:%M:%S # # Jan 1 01:05:59 #DAEMON_LOG_TIME_FORMAT = %b %d %I:%M:%S # ###################################################################### ... 생략 ... 자신의 서버에 맞는 DAEMON_LOG_TIME_FORMAT 을 선택한다. 재시작 한다. [root@www etc]# [root@www etc]# /etc/init.d/denyhosts stop [root@www etc]# /etc/init.d/denyhosts start 공격이 감지되면 hosts.deny에 바로 기록된다. 2. denyhosts 설정들 SECURE_LOG = /var/log/secure HOSTS_DENY = /etc/hosts.deny # 공격이 감지되면 hosts.deny에 바로 기록된다. PURGE_DENY = 5d # deny 된 ip들을 다시 놓아줄 기간 설정, 포맷방식-[dhwmy], (ex: 1h, 1d, 1w, 1y), 위에서는 5일로 설정, 생략하면 계속 deny 된다. BLOCK_SERVICE = sshd # ssh 또는 ftp 등 차단 감지할 서비스명 등록(디폴트: sshd) DENY_THRESHOLD_INVALID = 3 # 없는 계정으로 접속 시도한 IP의 차단 카운트, 없는 계정으로 접속했을 경우 3번까지는 봐주겠다. (디폴트: 5) DENY_THRESHOLD_VALID = 5 # 존재하는 계정으로 접속시도한 IP의 차단 카운트(디폴트: 10) DENY_THRESHOLD_ROOT = 3 # ROOT계정으로 접속시 차단 카운트 (디폴트:1) WORK_DIR = /usr/share/denyhosts/data # 차단 카운트 및 차단 ip 등의 데이터를 등록하는 데이터 경로 ADMIN_EMAIL = # deny ip 가 발생했을 때 보고를 받을 메일 주소 |
[목차] |