多くのディストリビューションで採用されているtelnetは,インターネット上でパスワードなどがテキスト形式のまま流れてしまうため,セキュリティ面で問題視されることが多い。
しかし,遠隔地からターミナル操作をしたいことは多々あるはずだ。このような場合には,ログイン手順から暗号化されるssh(secure shell)を利用するのがよい。ただし無償利用ができるといっても,sshは商用利用ができないので注意が必要だ。
ここでは,RPMパッケージを利用したインストール方法から設定,起動するまでを紹介する。手順とポイントは次の通りだ。
■主な手順
1. ここでは,http://rpmfind.net/linux/RPM/からダウンロード
2. RPMでインストール
3. クライアントログイン用の暗号キー作成
4. Windowsなどのクライアントからのログイン設定(「Windowsからsshログインをしたい」参照)
・インストール
まず最初に上のアドレスなどからダウンロードしたrpmファイルを,次のような手順でインストールしよう。インストール後には,パス設定されているディレクトリ下にサーバソフト,クライアントソフトなどが確認(# which sshdなどで)できるはずだ。
# rpm -Uvh ssh-2.3.0-1.i386.rpm ssh ########################################## Hostkey not found at /etc/ssh2/hostkey. Generating 1024-bit dsa key pair 2 Oo.oOo.oOOo. Key generated. 1024-bit dsa, root@mistio, Wed Oct 25 2000 14:45:01 +0900 Key is stored with NULL passphrase. (This is not recommended. 〜中略〜 Private key saved to /etc/ssh2/hostkey Public key saved to /etc/ssh2/hostkey.pub Assuming RedHat Linux compatible and trying to configure... Please make sure you haven't specified sshd in /etc/rc.d/rc.local If you already have sshd running, you should restart it or reboot. Configuration done. |
インストール後には,/etc/ssh2/下に次のようなファイルが作られている。
# ls -l /etc/ssh2/ total 20 -rw------- 1 root root 865 Oct 25 14:45 hostkey -rw-r--r-- 1 root root 734 Oct 25 14:45 hostkey.pub -rw-r--r-- 1 root root 1564 Aug 24 09:53 ssh2_config -rw-r--r-- 1 root root 122 Aug 24 09:13 ssh_dummy_shell.out -rw-r--r-- 1 root root 2293 Aug 24 19:06 sshd2_config |
sshd2の基本設定は,sshd2_configファイルで行う。
・クライアントで利用する暗号キーペアの作成
次に利用したい一般ユーザー名にログインをして,暗号キーペア(公開鍵と秘密鍵)作成をしよう。次のように「ssh-keygen」コマンドを実行すればよい。
# su [一般ユーザー名] $ ssh-keygen Generating 1024-bit dsa key pair 2 Oo.oOo.oOo.. Key generated. 1024-bit dsa, ykida@mistio, Wed Oct 25 2000 18:28:37 +0900 Passphrase : Again : Private key saved to /home/ykida/.ssh2/id_dsa_1024_a Public key saved to /home/ykida/.ssh2/id_dsa_1024_a.pub |
作成された暗号化キーは,フロッピーを利用してWindowsマシンなどへコピーしよう。この方法であれば,秘密キー(id_dsa_1024_a)が外部に漏れるのを防げるだろう。
Windowsマシンからssh経由でログインする方法は,「Windowsマシンからsshログインをしたい」Tipsを参考にしてほしい。
$ ls .ssh2/ id_dsa_1024_a id_dsa_1024_a.pub random_seed $ su Password: # mcopy .ssh2/* a: |
・sshdを起動するための設定
次の3つのファイルを参照し,ssh2が定義されていることを確認しよう。
# vi /etc/services ssh2 22/tcp # SSH Remote Login Protocol ssh2 22/udp # SSH Remote Login Protocol # vi /etc/inetd.conf ssh2 stream tcp nowait root /usr/sbin/tcpd /usr/local/sbin/sshd2 ←無ければ追加する # /etc/rc.d/init.d/inet restart ※さらに,hosts.allowファイルに次のようなアクセス制限設定をしておくとよいだろう。 # vi /etc/hosts.allow sshd: 192.168.22.0/255.255.255.0 |
最後にsshdを起動してみよう。起動方法は次の通りだ。マシン起動時に自動起動したい場合には,linuxconfなどで設定しておくのがよい。
# /etc/rc.d/init.d/sshd start |
linuxconf上であれば,/etc/rc.d/下のファイルを手動で編集しなくても,自動起動ができるように設定できる
Copyright © ITmedia, Inc. All Rights Reserved.