【 Solutions 】移除 offending ssh key

【 Solutions 】移除 offending ssh key

問題

  • 使用 ssh 遠端登入時出現下方錯誤訊息

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @    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:7utAoyUBxxs0ftPgnrklalsAtkDG8/M6ZPnrFvUxfh4. Please contact your system administrator. Add correct host key in /var/root/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /var/root/.ssh/known_hosts:12 ECDSA host key for 172.20.10.7 has changed and you have requested strict checking. Host key verification failed. 

解決方案

  • 移除發生問題的 key 紀錄

    • 下方訊息告知 /var/root/.ssh/known_hosts 檔案中的 第 12 行 造成無法遠端登入,故移除第 12 行的紀錄即可正常運作

    -----2019-12-17---4.09.51

    • 開啟 /var/root/.ssh/known_hosts 檔案

      sudo vi /var/root/.ssh/known_hosts 
      • 檔案內容
        -----2019-12-17---4.34.02
    • 顯示行號

      :set number 

      -----2019-12-17---4.34.14

    • 游標移到第 12 行再按 dd 即可刪除此行

      -----2019-12-17---4.34.22

      -----2019-12-17---4.34.34

    • 存檔並離開

      :wq! 

      -----2019-12-17---4.34.44

    • 重新登入

      • ㊟ 請修改所要登入的機器的 IP
      sudo ssh [email protected] 

      -----2019-12-17---4.59.23


GitHub
List of blogs