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?

[Linux] SSH接続時のホスト認証について

Last updated at Posted at 2025-04-11

この記事について

サーバにSSH接続する際、ホスト認証とユーザ認証が行われている。
本記事では、ホスト認証の仕組みについて記載する。

SSH接続における認証

SSH接続の際に行われる認証の順番としては、ホスト認証⇒ユーザ認証。

  • ホスト認証
    クライアントから見て、接続先のサーバーが信頼できるかどうかを確認する
  • ユーザ認証
    サーバーから見て、ユーザーが本人であるかを確認する

ホスト認証について

鍵ペアの生成(サーバー側)

サーバーにOpenSSH等のsshサービスがインストールされる際、以下の各鍵ファイルが生成される

  • 秘密鍵ファイル
[root@localhost ~]# ll /etc/ssh/ssh_host_rsa_key
-rw-r-----. 1 root ssh_keys 2578 Apr  2 11:06 /etc/ssh/ssh_host_rsa_key
  • 公開鍵ファイル
[root@localhost ~]# ll /etc/ssh/ssh_host_rsa_key.pub
-rw-r--r--. 1 root root 554 Apr  2 11:06 /etc/ssh/ssh_host_rsa_key.pub

SSH初回接続(クライアント側)

  1. クライアントからサーバーへの初回接続の際、サーバーは上述の公開鍵ファイルをクライアントに送信する。クライアントは、サーバーから受け取った公開鍵ファイルを以下ファイルに記録する。

    [root@localhost ~]# ll ~/.ssh/known_hosts
    -rw-r--r-- 1 root root 173  4月 10 17:10 /root/.ssh/known_hosts
    
  2. 受け取った公開鍵ファイルを信頼していいかどうかの確認が行われる

    • CLI画面
      Are you sure you want to continue connecting (yes/no/[fingerprint])?
    
    • Teraterm

    image.png

  3. 次回接続時、クライアントは接続先サーバーから送られてくる公開鍵情報が以下のファイルに存在しているか否かを確認する。存在していれば、ユーザー認証の段階に進む。以上。

[root@localhost ~]# ll ~/.ssh/known_hosts
-rw-r--r-- 1 root root 173  4月 10 17:10 /root/.ssh/known_hosts
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?