Hack 13. SSH を使用してリモート干すとにログインする
はじめてローカルホストからリモートホストにログインする際に、
ホストキーがみつからないというメッセージが表示され、続けるには“yes”を入力します。
リモートホストのホストキーは以下に示すようにホームディレクトリの .ssh2/hostkeys ディレクトリに追加されます。
localhost$ ssh -l jsmith remotehost.example.com Host key not found from database. Key fingerprint: xabie-dezbc-manud-bartd-satsy-limit-nexiu-jambl-title-jarde-tuxum You can get a public key’s fingerprint by running % ssh-keygen -F publickey.pub on the keyfile. Are you sure you want to continue connecting (yes/no)? Yes Host key saved to /home/jsmith/.ssh2/hostkeys/key_22_remotehost.example.com.pub host key for remotehost.example.com, accepted by jsmith Mon May 26 2008 16:06:50 -0700 jsmith@remotehost.example.com password: remotehost.example.com$
2回目にローカルホストからリモートホストにログインする際に、
リモートホストキーが ssh クライアントの known hosts に既に追加されているため
パスワードだけ入力表示されます。
localhost$ ssh -l jsmith remotehost.example.com jsmith@remotehost.example.com password: remotehost.example.com$
同じ理由から、最初にログインした後にリモートホストのホストキーが変更された場合、
以下に示すように警告メッセージがでるかもしれません。
これは以下のようなさまざまな理由があるためです。
o 管理者がリモートホストの SSH サーバ を更新または再インストールした
o だれかが悪意のある行為をしたなど
以下のメッセージに対して“yes”と応えるまえにとるべき最も有効なのは、
管理者を呼ぶことです。
そしてなぜホストキーが変わったメッセージが出たのかを確認し、
ホストキーが正しいかどうかを確認します。
localhost$ ssh -l jsmith remotehost.example.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: 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 host key has just been changed. Please contact your system administrator. Add correct host key to “/home/jsmith/.ssh2/hostkeys/key_22_remotehost.example.com.pub” to get rid of this message. Received server key’s fingerprint: xabie-dezbc-manud-bartd-satsy-limit-nexiu-jambl-title-arde-tuxum You can get a public key’s fingerprint by running % ssh-keygen -F publickey.pub on the keyfile. Agent forwarding is disabled to avoid attacks by corrupted servers. Are you sure you want to continue connecting (yes/no)? yes Do you want to change the host key on disk (yes/no)? yes Agent forwarding re-enabled. Host key saved to /home/jsmith/.ssh2/hostkeys/key_22_remotehost.example.com.pub host key for remotehost.example.com, accepted by jsmith Mon May 26 2008 16:17:31 -0700 jsmith @remotehost.example.com’s password: remotehost$