目次
せっかくなのでリモートでメンテを行えるようにする。
クライアントはWindowsXPでPuTTyを利用し、通信はSSHで暗号化する。
yum remove opensshopenssh,openssh-clients,openssh-serverが削除される。
# wget -P /usr/local/src http://openssh.linux-mirror.org/portable/openssh-4.7p1.tar.gz
# cd /usr/local/src # tar zxvf openssh-4.7p1.tar.gz
# cd /usr/local/src/openssh-4.7p1 # ./configure \ > --prefix=/usr/local/openssh-4.7p1 \ > --with-tcp-wrappers \ > --with-ssl-dir=/usr/local/ssl \ > --with-privsep-user=sshd \ > --with-privsep-path=/var/empty/sshd
# make # make install
# ln -s /usr/local/openssh-4.7p1 /usr/local/ssh
# vi /usr/local/ssh/etc/sshd_config #Port 22 ↓ Port 22 #SyslogFacility AUTH ↓ SyslogFacility AUTH #PermitRootLogon yes ↓ PermitRootLogon no ← rootでのログインを禁止 #AuthorizedKeysFile .ssh/authorized_keys ↓ AuthorizedKeysFile .ssh/authorized_keys #PasswordAuthentication yes ↓ PasswordAuthentication no ← パスワードでのログインを禁止(鍵方式によるログインのみ許可) #PermitEmptyPasswords no ↓ PermitEmptyPasswords no ← パスワードなしでのログインを禁止
# cp /usr/local/src/openssh-4.7p1/contrib/redhat/sshd.init /etc/rc.d/init.d/sshd
# vi /etc/rc.d/init.d/sshd KEYGEN=/usr/bin/ssh-keygen ↓ KEYGEN=/usr/local/ssh/bin/ssh-keygen SSHD=/usr/sbin/sshd ↓ SSHD=/usr/local/ssh/sbin/sshd RSA1_KEY=/etc/ssh/ssh_host_key ↓ RSA1_KEY=/usr/local/ssh/etc/ssh_host_key RSA_KEY=/etc/ssh/ssh_host_rsa_key ↓ RSA_KEY=/usr/local/ssh/etc/ssh_host_rsa_key DSA_KEY=/etc/ssh/ssh_host_dsa_key ↓ DSA_KEY=/usr/local/ssh/etc/ssh_host_dsa_key※SSHサーバー起動時に以下のワーニングメッセージが出力されることの対処
〜start()の中〜 initlog -c "$SSHD $OPTIONS" && success || failure ↓ #initlog -c "$SSHD $OPTIONS" && success || failure ← 元の行をコメントアウト $SSHD $OPTIONS && success || failure ← 代わりに追加
# chmod 755 /etc/rc.d/init.d/sshd # chkconfig --add sshd # chkconfig sshd on # chkconfig --list sshd sshd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
# su - XXXXX $ /usr/local/ssh/bin/ssh-keygen -t rsa ← SSH2で公開鍵・秘密鍵を作成 Generating public/private rsa key pair. Enter file in which to save the key (/home/kaz/.ssh/id_rsa): ← 鍵のファイル名を入力(空EnterでOK) Created directory '/home/XXXXX/.ssh' Enter passphrase (empty for no passphrase): ← パスフレーズの入力 Enter same passphrase again: ← パスフレーズの再入力 Your identification has been saved in /home/XXXXX/.ssh/id_rsa. Your public key has been saved in /home/XXXXX/.ssh/id_rsa.pub. The key fingerprint is: 〜鍵情報が表示される〜
$ cd .ssh $ ls -la 合計 16 drwx------ 2 XXXXX XXXXX 4096 3月 8 21:22 . drwx------ 16 XXXXX XXXXX 4096 3月 8 20:33 .. -rw------- 1 XXXXX XXXXX 951 3月 8 21:22 id_rsa ← 秘密鍵 -rw-r--r-- 1 XXXXX XXXXX 241 3月 8 21:22 id_rsa.pub ← 公開鍵
$ cd ~/.ssh $ cat id_rsa.pub >> authorized_keys $ rm -f ~/.ssh/id_rsa.pub ← 元の鍵を削除authorized_keysがない場合
$ cd ~/.ssh $ mv id_rsa.pub authorized_keys
$ chmod 400 ~/.ssh/authorized_keys
# cp /home/XXXXX/.ssh/id_rsa /mnt/floppyフロッピーにコピーされたid_rsaファイルを使用してPuTTyの接続設定を行う。