Ssh

SSH 進入一個經常更改 IP 的盒子

  • December 21, 2020

我有一些經常更改 IP 的雲盒。

我使用主機名進行 ssh,但由於此錯誤消息,每次伺服器啟動時都必須編輯 known_hosts 文件:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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…

除了與我想做的事情相關的任何安全風險之外,有沒有辦法忽略此錯誤或自動覆蓋 known_hosts 文件,這樣我就不必總是自己編輯它?

編輯您的 ssh_config 文件並添加更改此行:

CheckHostIP no

CheckHostIP 預設為“是”。這樣做只是為了做你沒有通過的那種檢查。關閉它意味著它只相信 IP 是可變的,並且會針對主機名進行密鑰檢查。

另外:您可以嘗試僅禁用該名稱的 CheckHostIP 檢查:

Host *
 [ global settings .. ]

Host very.dynamic.host
 CheckHostIP no

引用自:https://serverfault.com/questions/193631