Contents

1. sshとは

1.1 ssh(Secure Shell)とはなにか

ssh(Secure Shell)は、UNIXで用いられるリモートシェルです。sshはデータを暗号化して通信するため、同様のプログラムであるtelnetと比べて安全に使うことができます。

また、ログイン方法も従来のアカウント・パスワードではなく、公開鍵暗号による方法が使えます。
ネットワークにパスワードが流れないため、より安全に使うことができます。

セキュリティのためにはssh+公開鍵暗号を使うことが推奨されます。

2. sshのインストール

2.1 sshをインストールする

sshはdebianのパッケージで提供されています。ここではaptitudeコマンドを使って、sshをインストールします。
次の手順でsshをインストールします。

  1. rootでログインします。
    debian login: root
    debian:~# 
  2. aptitudeコマンドでsshをインストールします。
    debian:~# aptitude -y install ssh
     .
     .
     .
    openssh-server (4.3p2-9etch2)          ...
    Creating SSH2 RSA key; this may take some time ...
    Creating SSH2 DSA key; this may take some time ...
    NET: Registered protocol family 10
    lo: Disabled Privacy Extensions
    Restarting OpenBSD Secure Shell server: sshd.
    
    ssh (4.3p2-9etch2)          ...
    debian:~# 

以上で、sshのインストールは終了です。

2.2 sshの設定

現状では、sshでログインすることはできません。rootでログインできるよう設定を書き換えます。
次の手順で、sshを設定します。

  1. sshd_configでrootのログインを許可します。
    /etc/ssh/sshd_config
    PasswordAuthentication yes
    PermitRootLogin yes
    
  2. sshサーバを再起動します。
    debian:~# /etc/init.d/ssh restart
    Restarting OpenBSD Secure Shell server: sshd.
    debian:~# 
  3. ログイン用にrootにパスワードを設定します。今回は'root'とします。
    debian:~# passwd
    Enter new UNIX password: root
    Retype new UNIX password: root
    passwd: password updated successfully
    debian:~# 

以上で、sshの設定は終了です。

2.3 sshの動作チェック

2.2までが成功すれば、sshでログインできます。
次の手順で、sshの動作をチェックします。

  1. rootでログインします。
    debian login: root
    Password: root
    debian:~# 
  2. sshでdebianにログインします。
    debian:~# ssh debian
    root@debian's password: root
    Last login: Fri Aug  8 10:53:48 2008
    Linux debian 2.6.22.18-co-0.7.3 #1 PREEMPT Sat May 24 22:27:30 UTC 2008 i686
    
    The programs included with the Debian GNU/Linux system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.
    
    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    debian:~# 

以上のようにsshでログインできれば、sshのインストールは成功です。

Google