0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWSで秘密鍵を変更した場合のターミナル「WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!」への対処法

Posted at

AWSのEC2サーバに、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.
(以下略)

#原因
SSHがもつセキュリティ機能として、前回保存しておいた秘密鍵と異なる秘密鍵でログインしようとすると上記のような確認メッセージを出すようになっています。
意図的に変更したのであれば秘密鍵が変わっていることは全く問題ないので、以下の対処をしてログインします。

#対処1
/.ssh/known_hosts
に記載されている内容を、エディタ上で削除する。

※ known_hosts:前回保存した秘密鍵の情報

#対処2

(対処1が面倒な方)
以下コマンドから前回の秘密鍵情報を削除する。

ssh-keygen -R example.com

#結果

再度ログインすると、いつものコレが表示されるはずです。

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

以上です。最後まで読んでいただきありがとうございました!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?