2月 18, 2020 Network
Home Office 了一段時間因為有點 Server 問題回到公司去解決,但誰知道在沒有動 Server 一段時間後在連上 SSH 時發生問題 !!

### 發現問題

大約是因為這台 Server 的 Fingerprint 和先前連上時不同了,為了防止第三方的人士 "扮" 是連線目標的主機,所以引發這個問題。

```sh
$ ssh root@192.168.1.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:HDjXJcb0VYXWF+MCBDjSGn6FQmg/+x7vV0ljJvIDas0.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:46
ECDSA host key for 192.168.1.1 has changed and you have requested strict checking.
Host key verification failed.
```

說明了是 Host key changed

```sh
ECDSA host key for 192.168.1.1 has changed and you have requested strict checking.
Host key verification failed.
```

Host key Changed 可能有好多原因,最有可能是因為主網重新安裝了 ... 果然 ... 目標的伺服器是更新了。

### 解決方法

針對因為 Host Key Changed 的問題,只需要把本機的 Host Key 記錄清除。

```sh
$ ssh-keygen -R 192.168.1.1
```

這樣就可以把 `/root/.ssh/known_hosts` 的有關 `192.168.1.1` 的 Key 記錄清除,這樣下次連線是就會重新查問是否連線到 `192.168.1.1`。之後回答 `yes` 便可以了。
過去文章
2025 (9)
4 (5)
3 (1)
2 (3)
2024 (25)
11 (3)
10 (3)
9 (1)
3 (18)
2022 (6)
10 (1)
6 (2)
5 (1)
3 (1)
1 (1)
2021 (21)
11 (7)
7 (1)
6 (2)
5 (2)
4 (6)
3 (2)
2 (1)
2020 (92)
12 (1)
11 (2)
10 (4)
9 (10)
8 (5)
7 (1)
6 (3)
5 (1)
4 (4)
3 (25)
2 (7)
1 (29)
2019 (57)
12 (25)
11 (7)
9 (25)