피드로 돌아가기
Understanding known_hosts and Host Key Verification: What It Protects Against and How TOFU Works
Dev.toDev.to
Security

TOFU 모델 기반 Host Key Verification을 통한 MITM 공격 원천 차단

Understanding known_hosts and Host Key Verification: What It Protects Against and How TOFU Works

Mahafuzur Rahaman2026년 5월 28일11intermediate

Context

IP Spoofing 및 DNS Poisoning으로 인한 서버 사칭 위협 존재. 네트워크 경로상에서 데이터가 탈취되는 Man-in-the-Middle(MITM) 공격을 방지하기 위한 서버 신원 증명 메커니즘 필요.

Technical Solution

  • 서버 설치 시 자동 생성되는 Public/Private Key Pair 기반의 Cryptographic Identity 구축
  • Trust On First Use(TOFU) 모델을 통한 최초 연결 시 Public Key의 Fingerprint 확인 및 ~/.ssh/known_hosts 저장
  • 이후 연결 시 저장된 Public Key와 서버 제시 키의 일치 여부를 검증하는 Host Key Verification 수행
  • StrictHostKeyChecking 설정을 통해 unknown host 거부(yes) 또는 신규 키 자동 수용(accept-new) 등 보안 수준 제어
  • Hostname Hashing 기법을 적용하여 known_hosts 파일 유출 시 연결 대상 서버 목록 노출 방지

- 민감 서버 최초 연결 시 Out-of-band 채널을 통한 Fingerprint 교차 검증 수행 - Host Key 변경 경고 발생 시 무조건적인 삭제 대신 원인 분석 및 조사 우선 - 생산성과 보안의 균형을 위해 StrictHostKeyChecking 값을 accept-new로 설정 검토 - ssh-keygen -R 명령어를 통한 주기적인 Stale Entry 정리 및 hygiene 유지

원문 읽기