Linux サーバ構築演習 回答例(ssh)

今回の ssh 演習は、以下を想定しています。実際に使うマシンが同一であるため、 混乱しないよう注意が必要です。

Solution

  1. SSH クライアント設定
    Machine AMachine B
    yakoshi$ ssh-keygen -t dsa
    Generating public/private dsa key pair.
    Enter file in which to save the key (/home/yakoshi/.ssh/id_dsa):_
    Enter passphrase (empty for no passphrase):**********
    Enter same passphrase again:**********
    Your identification has been saved in /home/yakoshi/.ssh/id_dsa.
    Your public key has been saved in /home/yakoshi/.ssh/id_dsa.pub.
    The key fingerprint is:
    46:58:b0:be:3b:ed:2f:0c:54:59:45:c5:24:a7:7a:a6 yakoshi@umejima-2.ppp-bb.dion.ne.jp
    yakoshi$ scp ~/.ssh/id_dsa.pub student@localhost:yakoshi.pub
    student@localhost's password:
    id_dsa.pub                      100%  622     0.6KB/s   00:00 ETA 
    student$ cd ~
    student$ mkdir .ssh
    student$ cat yakoshi.pub >> .ssh/authorized_keys
    student$ chmod 700 .ssh
    student$ chmod 600 .ssh/authorized_keys  
    yakoshi$ ssh student@localhost
    Enter passphrase for key '/home/ycos/.ssh/id_dsa':********* #← パスフレーズが聞かれること
    Last login: Sat Dec 25 22:52:34 2010 from localhost.localdomain
    student$

  2. /etc/ssh/sshd_config 設定例
    上記クライアントの設定が確実に行われている状態で、下記設定を行う。
    #Protocol 2,1
    Protocol 2
    PermitRootLogin no
    PasswordAuthentication no