본문 바로가기

컴퓨터와 인터넷

Denyhosts 설치방법 (SSH 공격방지)

반응형

DenyHosts 설치로 SSH 공격 방지~



다운로드:

http://sourceforge.net/projects/denyhosts/files/



설치:

python setup.py install

cd /usr/share/denyhosts

cp denyhosts.cfg-dist denyhosts.cfg


cp daemon-control-dist daemon-control


vi /usr/share/denyhosts/daemon-control


설정파일이 아래와 같은지 확인한다.

DENYHOSTS_BIN = "/usr/bin/denyhosts.py"

DENYHOSTS_LOCK = "/var/run/denyhosts.pid"

DENYHOSTS_CFG = "/usr/share/denyhosts/denyhosts.cfg"


chown root daemon-control

chmod 700 daemon-control


cd /etc/init.d

ln -s /usr/share/denyhosts/daemon-control denyhosts

update-rc.d denyhosts defaults

만약 update-rc.d 가 command not found 라면 아래와 같이 한다.

chkconfig --add denyhosts

chkconfig --list denyhosts


/etc/init.d/denyhosts start


명령어:

daemon-control start  데몬시작

daemon-control stop 데몬중지

daemon-control restart  재시작

daemon-control debug 디버그

daemon-control status 상태


혹시라도 본인의 IP가 차단되는 불상사가 없도록

hosts.allow 에 IP를 등록하자.

vi /etc/hosts.allow

ALL : 123.000.00.111(본인아이피)


차단된 IP는 hosts.deny에서 삭제해주면 된다.


에러발생시 참고:

1) update-rc.d command not found 라고 나오면

chkconfig --add denyhosts


2) DenyHosts could not obtain lock (pid: 36854)

[Errno 17] File exists: '/var/lock/subsys/denyhosts'


이렇게 나오면 해당파일 삭제 후 다시 실행.



반응형