원격 서버를 관리하기 위해서 ssh 서버를 주로 사용합니다.
하지만 외부에 공개되어 있는 만큼 공격 시도가 자주 들어오고는 합니다.
fail2ban 을 사용하여 ssh 서버에 대한 무작위 로그인 시도를 방어하는 방법에 대해 알아보겠습니다.
fail2ban이란?
fail2ban은 로그인 실패 로그를 지속적으로 검사하며, 특정 아이피에서 너무 많은 로그인 실패 기록이 감지될 경우 해당 IP 주소로부터의 새 연결을 거부하도록 방화벽을 설정하는 프로그램입니다.
https://github.com/fail2ban/fail2ban
GitHub - fail2ban/fail2ban: Daemon to ban hosts that cause multiple authentication errors
Daemon to ban hosts that cause multiple authentication errors - fail2ban/fail2ban
github.com
글 작성일 (24/04/22)기준 깃헙 스타 10.4k를 달성한 프로젝트입니다.
fail2ban 설치
sudo apt update
sudo apt install fail2ban
서비스 등록
시스템 재시작 시에도 제대로 작동할 수 있게 서비스 등록해 줍니다.
sudo systemctl enable fail2ban
sudo systemctl restart fail2ban
sudo systemctl status fail2ban
fail2ban 기본 설정이 완료되었습니다.
단, fail2ban은 잘못된 인증 시도를 감소시켜 줄 뿐 기본적으로 약한 인증에 대해서는 방어하지 못한다는 점을 꼭 인지하셔야 합니다.
깃허브 readme 발췌
Though Fail2Ban is able to reduce the rate of incorrect authentication attempts, it cannot eliminate the risk presented by weak authentication. Set up services to use only two factor, or public/private authentication mechanisms if you really want to protect services.
'리눅스' 카테고리의 다른 글
리눅스 노트북 키보드 한글 입력 설정하기(한영키 활성화) (0) | 2024.07.23 |
---|---|
fedora 40 + kde 6 한글 입력 구성하기 (0) | 2024.07.23 |
TLP를 활용한 리눅스 노트북 충전 제한 설정하기 (0) | 2024.04.23 |
리눅스(Ubuntu) ssh 서버 설치 및 접속 설정하기 (0) | 2024.04.23 |