それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

SSHでknown_hostsをの警告無視する設定はどうなるか?

Known_hostsのhost keyが変わってエラーに成って、Y/Nが出てくるのが面倒くさいのでなんとからないかなと思ってやってみた。

 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

警告を無視する設定

設定はこれ

takuya@air:~$ ssh takuya.example.com -o "StrictHostKeyChecking no"

"StrictHostKeyChecking no"をつければいいらしい。 .ssh/config に書いたら全部に有効になると思う。alias でもいいね。

どうなるか知ってる?

僕もわからない。とりあえずやってみる。

  1. 対象のホストにつないで、host 鍵を保存する
  2. /etc/hostsを書き換えてホスト名を上書き
  3. 違う鍵が来るようにしてエラーがどう変わるか見る

まず鍵を保存する。

.ssh/known_hostsの鍵を空っぽにして・・・
つなぐ

ssh takuya.example.com

これでホスト鍵が保存される。

/etc/hostsを書き換えて・・・

  1 ##
  2 # Host Database
  3 #
  4 # localhost is used to configure the
  5 # when the system is booting.  Do not
  6 ##
  7 127.0.0.1 localhost
  8 255.255.255.255 broadcasthost
  9 ::1             localhost
 10 fe80::1%lo0 localhost
 11
 12 192.168.xxx.xx xxxxx.ddd.jp
 13
 14 19.168.12.11 takuya.example.jp #<---------------書き換えた
 15
~                                       

接続した。

ホスト鍵が変わっているので通常はY/Nダイアログになる。

オプションをつけた場合は、そのままメッセージが出て、接続された。

takuya@air:~$ ssh takuya.example.jp -o "StrictHostKeyChecking no"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for takuya.mine.nu has changed,
and the key for the corresponding IP address 192.168.xxxxx
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /Users/takuya/.ssh/known_hosts:3
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
08:cf:c1:88:8e:6fxxxxx:xxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/takuya/.ssh/known_hosts to get rid of this message.
Offending key in /Users/takuya/.ssh/known_hosts:13
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
Last login: Wed Feb  1 22:05:59 2012 from 192.168.xxxxx
takuya@debian00:~$  #<---------------------------------------------------------接続された
takuya@debian00:~$ logout
Connection to takuya.example.com closed.

ためみしてみた結果

ホスト鍵が変わっても、ダイアログは出ずに、「警告」と「書き換えたよ」ってメッセージが出てくる。


無条件に受け入れて、ファイルを更新することがわかる。

結論

オプションをつけると、鍵か変わってたら、メッセージだして、上書きする


ということで、あまりよくない。常時有効にするのは良くなさそうですね。

dnsラウンドロビンでコロコロ変わるときにつかえる。。。かも