Show Table of Contents
12.3. OpenSSH クライアント
クライアントマシンから OpenSSH サーバーに接続するには、openssh-clients および openssh パッケージがインストールされている必要があります (Red Hat Enterprise Linux に新規パッケージをインストールする方法については 「パッケージのインストール」 を参照して下さい)。
12.3.1. ssh ユーティリティの使用
ssh ユーティリティを使用すると、リモートマシンにログインしてそのマシン上でコマンドを実行することできます。これは、rlogin、rsh および telnet プログラムに代わるセキュアな手段です。
telnet と同様に、リモートマシンにログインするには、以下のコマンドを入力します。
ssh hostname
例えば、
penguin.example.com という名前のリモートマシンにログインするには、シェルプロンプトで以下を入力します。
~]$ ssh penguin.example.com
これによって、ローカルマシンで使用しているのと同じユーザー名でログインします。別のユーザー名を指定したい場合には、以下の形式のコマンドを使用してください。
ssh username@hostname
例えば、
john として penguin.example.com にログインするには、以下のように入力します。
~]$ ssh john@penguin.example.com
初回接続時には、以下のようなメッセージが表示されます:
The authenticity of host 'penguin.example.com' can't be established. RSA key fingerprint is 94:68:3a:3a:bc:f3:9a:9b:01:5d:b3:07:38:e2:11:0c. Are you sure you want to continue connecting (yes/no)?
yes と入力して確定します。サーバーが既知ホストの一覧に追加されたことを知らせるメッセージとパスワードの入力を求めるプロンプトが以下のように表示されます:
Warning: Permanently added 'penguin.example.com' (RSA) to the list of known hosts. john@penguin.example.com's password:
重要
SSH サーバーのホスト鍵が変更された場合、クライアントはサーバーのホスト鍵が
~/.ssh/known_hosts ファイルから削除されるまで接続を続行できないことをユーザーに知らせます。サーバーのホスト鍵を削除するには、そのファイルをテキストエディターで開いて、対象のリモートマシン名が冒頭に記載されている行を削除します。ただし、これを実行する前に、SSH サーバーのシステム管理者に連絡してサーバーが侵害を受けていないことを確認して下さい。
パスワードを入力すると、リモートマシン用のシェルプロンプトが表示されます。
別の方法として、シェルプロンプトにログインせずに、
ssh プログラムを使用してリモートマシン上でコマンドを実行することができます。
ssh [username@]hostname command
例えば、
/etc/redhat-release ファイルは Red Hat Enterprise Linux のバージョンに関する情報を提供します。penguin.example.com でこのファイルの内容を表示するには、以下を入力します。
~]$ ssh john@penguin.example.com cat /etc/redhat-release
john@penguin.example.com's password:
Red Hat Enterprise Linux Server release 6.2 (Santiago)
正しいパスワードを入力すると、ユーザー名が表示され、ローカルのシェルプロンプトへ戻ります。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.