使用 git
命令或 ssh
命令时出现如下提示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
SHA256:xxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/xxx/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/xxx/.ssh/known_hosts:1
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
|
Solution¶
执行如下命令,找到输出中 github.com
对应的 IP 地址。
1
|
ssh-keygen -lf ~/.ssh/known_hosts
|
比如:
1
|
256 SHA256:xxxxxxxxxxxxxxxx github.com,13.250.177.223
|
对找到的 IP 地址(e.g. 13.250.177.223
),执行:
1
|
>>>> $ ssh-keygen -R 13.250.177.223
|
完成!
执行成功后会有如下输出:
1
2
3
|
# Host 13.250.177.223 found: line 1
/Users/xxx/.ssh/known_hosts updated.
Original contents retained as /Users/xxx/.ssh/known_hosts.old
|
再执行 git
或 ssh
命令时会有如下提示,输入 yes
即可。
1
|
Are you sure you want to continue connecting (yes/no)?
|