SSH 접속하는데 Host key 어쩌구 하면서 접속이 안될때
Sometimes when connecting to a computer with SSH, things can get jumbled up and an error can occur that looks like this:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5c:9b:16:56:a6:cd:11:10:3a:cd:1b:a2:91:cd:e5:1c.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for ras.mydomain.com has changed and you have requested strict checking.
Host key verification failed.
1 known_hosts 파일을 아래와 같이 clear한다.
2 ssh-keygen -R x.x.x.x 방식으로 키젠을 생성해 본다.
그래도 안되면
3 ssh -T git@gitlab.com 방식으로 재접속해 본다.
출처 ::
https://stackoverflow.com/questions/68332819/ssh-known-hosts-no-such-file-or-directory
Clearing the known_hosts SSH File
Method 1 - Getting Rid of It All
If you only have one host in your know_host file then removing the entire file is a solution. The file will be recreated the next time you ssh into that computer. Before you remove the file you should back up the contents:
cp ~/.ssh/known_hosts ~/.ssh/known_hosts.old
[abc123@computer ~]rm ~/.ssh/known_hosts
Method 2 - Targeting the Key Individually
If you look at the error message you will notice this line:
RSA host key for ras.mydomain.com has changed...
This tells which is the offending host, so now you can remove that key by running:
[abc123@computer ~]ssh-keygen -R HOSTNAME
This will give you the following output when it is successful:
출처 :: https://www.rit.edu/researchcomputing/instructions/Clearing-the-known_hosts-SSH-File