profaim  >  関連ソフトウェア  >  ネットワーク  >  SSH  >  Tips  >  SSHサーバーが変わったら

SSHサーバーが変わったら

記載日:2010/6/16
ネットワーク技術 SSH

1.SSH リモートホストの変更を検知

1度でも SSH で接続したことあるサーバー(リモートホスト)は、クライアント上に記録されています。初めて SSH で接続を試みた際に「接続したいのはこのホストで間違いないか?」という旨の表示が出て "yes" と入力していたはずです。この時点で SSHのクライアントソフトが「確認済みのリモートホスト」として リモートホストの IPアドレス と リモートホストを特定するための ホストキー を対にして記録しています。

このホストキーはリモートホスト毎に固有の値になるため、リモートホストを別のコンピューターに置き換えたり、OSを再インストールしなおしたりするとホストキーも別の値になってしまい、クライアントでは 「 IPアドレス は登録されているが、確認した時のものではない。」と警告が通知されます。

$ ssh user@192.168.1.10
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Please contact your system administrator.
Add correct host key in /user/.ssh/known_hosts to get rid of this message.
Offending key in /user/.ssh/known_hosts:4
RSA host key for 192.168.1.10 has changed and you have requested strict checking.
Host key verification failed.

$

2.SSH リモートホストを確認し直す

この警告(WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!)が表示された場合は、 クライアント上でもう一度リモートホストの確認処理を行う必要があります。

ファイルから確認済みの記録を削除

出力中に "Add correct host key in /user/.ssh/known_hosts" とあるように、今回の場合では /user/.ssh/known_hosts ファイルに収集したホストキーが登録されていることがわかります。まずはこのファイルをVIエディタでなどで開き、1行ずつ書き込まれている IPアドレス と ホストキー の該当行を削除します。

$ vi /user/.ssh/known_hosts

192.168.1.40 ssh-rsa 6SFSfpttpL0w17gIlkbDhK7RqXB・・・
192.168.1.30 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQE・・・
192.168.1.20 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQE・・・
192.168.1.10 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA・・・

今回は対象の 192.168.1.10 の行(4行目)を削除しました。

再度 SSH 接続

再度、SSH でリモートホストへの接続を行います。

$ ssh user@192.168.1.10
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?


冒頭の警告文ではなく「確認が済んでいないホストだが接続していいか?」を確認してくるので、yes を入力します。

Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts.
user@192.168.1.10's password:


これで無事 SSH リモートホスト に接続できるようになりました。後の操作はいつもの SSH と同じです。






  SSH  
Tips
SSHサーバーが変わったら

PR
検索
カスタム検索