15.1.2 호스트인증
- SSH는 서버에 접속하면 그때마다 호스트 인증을 수행한다.
- 먼저 서버는 서버 고유의 호스트 키(공개키)를 클라이언트에게 전달하고, 클라이언트 쪽에서 저장하고 있는 호스트 키와 비교하여 일치 여부를 확인함
- 처음 서버에 접속할때는 클라이언트에 등록된 호스트키가 없으므로 등록되어있지 않은 호스트 키임을 사용자에게 알려줌
$ ssh [email protected]
The authenticity of host 'jongpak.com (192.168.0.1)' can't be established.
RSA key fingerprint is xx:xx:xx:e5:xx:de:46:18:56:7c:87:5f:c0:11:21:xx.
Are you sure you want to continue connecting (yes/no)?
- 위 화면에서 yes를 입력하면
~/.ssh/known_hosts 파일에 호스트키가 등록됨 (등록전에 fingerprint를 확인해야함)
- 등록된 서버의 호스트키와 다르다면 아래와 같이 경고가 표시됨
- 만약 접속하고자 하는 서버의 fingerprint와 다르다면 중간자 공격을 의심해야함 (Man-in-the-Middle)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
xx:xx:xx:19:11:85:d4:06:d9:47:7f:f7:da:50:8a:f9.
Please contact your system administrator.
Add correct host key in /home/jongpak/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/jongpak/.ssh/known_hosts:2
RSA host key for 192.168.0.1 has changed and you have requested strict checking.
Host key verification failed.
호스트키 (/etc/ssh/ssh_host_*)
- OpenSSH를 설치하면 호스트의 공개키와 비밀키가
/etc/ssh 디렉토리 하위에 만들어짐
- 비밀키는 절대 외부에 노출되지 않도록 관리를 해야함
- 서버 호스트키의 핑거트린드를 확인하려면
ssh-keygen 명령에 -l 옵션을 붙여 확인 가능
$ ssh-keygen -l
Enter file in which the key is (/home/jongpak/.ssh/id_rsa):
2048 SHA256:ZXXXF5Ikdco13RpTRChunJCeYsAOvIXGZ8uL2EF/NQA [email protected] (RSA)