7
7

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.

ec2インスタンスとの接続でknown_hostsを書き込まなくする

Posted at

ec2インスタンスの実態が変わるたびに、known_hostsを削除する必要が出てきます。
めんどくさくなってGoogle検索していたら解決策がありました。

~/.ssh/config に以下を記述します。

Host *.amazonaws.com
   StrictHostKeyChecking no
   UserKnownHostsFile /dev/null 

これでec2のHostKey(サーバ側のkey)をチェックしないで、クライアントのknown_hostsにも書き込みません。

ただ、 man in the middle が可能になります。
クライアントからサーバへの経路のどこかで、サーバをなりすますことができれば、偽物のサーバにログインしていてもクライアントは気づかないことになります。

クライアント <=>  悪いやつ(man) <=> サーバ

そのリスクを理解して設定するか、消すかです。
あとは、以下のようにコマンドラインから消すことも可能です。

$ssh-keygen -R "ec2-wantremovecode.amazon.com"
7
7
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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?