#freeze
''目次''
#contents
~
----

*目的 [#v4749f2b]
せっかくなのでリモートでメンテを行えるようにする。~
クライアントはWindowsXPで[[PuTTy:http://www.chiark.greenend.org.uk/%7Esgtatham/putty/]]を利用し、通信はSSHで暗号化する。

*準備 [#af8e63c0]
-[[zlib>http://www.gzip.org/zlib/]]
 # yum install zlib-devel
~
-tcp_wrappers-devel
 # yum install tcp_wrappers-devel
~
-[[OpenSSL>http://www.openssl.org/]]


*インストール [#a98b13d0]

+''ソースの取得''
 # wget -P /usr/local/src http://ftp.jaist.ac.jp/pub/OpenBSD/OpenSSH/portable/openssh-5.9p1.tar.gz
~
+''ソースの解凍''
 # cd /usr/local/src
 # tar zxvf openssh-5.9p1.tar.gz
~
+''コンパイル設定''~
[[configureのヘルプ>OpenSSH 5.9p1のconfigureヘルプ]]
 # cd /usr/local/src/openssh-5.9p1
 # ./configure \
 > --prefix=/usr/local/openssh-5.9p1 \
 > --with-tcp-wrappers \
 > --with-ssl-dir=/usr/local/ssl \
 > --with-privsep-user=sshd \
 > --with-privsep-path=/var/empty/sshd
~
''tcp_wrappers-devel'' がないとconfigureの途中で怒られる。
 checking for libwrap... configure: error: *** libwrap missing
~
+''インストール''
 # make
 # make install
~
+''シンボリックリンクの作成''
 # ln -s /usr/local/openssh-5.9p1 /usr/local/ssh

*設定 [#y554b6e7]
+''sshd_confの設定''
 # vi /usr/local/ssh/etc/sshd_config
 
 #Port 22
 ↓
 Port 22
 
 #SyslogFacility AUTH
 ↓
 SyslogFacility AUTH
 
 #PermitRootLogin yes
 ↓
 PermitRootLogin no                ← rootでのログインを禁止
 
 #PasswordAuthentication yes
 ↓
 PasswordAuthentication no         ← パスワードでのログインを禁止(鍵方式によるログインのみ許可)
 
 #PermitEmptyPasswords no
 ↓
 PermitEmptyPasswords no           ← パスワードなしでのログインを禁止
~
+''起動スクリプトのコピー''~
ソースの中にある起動スクリプトをコピーする
 # cp /usr/local/src/openssh-5.9p1/contrib/redhat/sshd.init /etc/rc.d/init.d/sshd
~
+''起動スクリプトの編集''~
[[デフォルト起動スクリプト>デフォルト起動スクリプト OpenSSH 5.9p1]]
 # vi /etc/rc.d/init.d/sshd
 
 SSHD=/usr/sbin/sshd
 ↓
 SSHD=/usr/local/ssh/sbin/sshd
start()の中
 /usr/bin/ssh-keygen -A
 ↓
 /usr/local/ssh/bin/ssh-keygen -A
~
+''起動スクリプトの登録''
 # chkconfig --add sshd
 # chkconfig sshd on
 # chkconfig --list sshd
 sshd            0:off   1:off   2:off   3:on    4:on    5:on    6:off

*鍵の作成 [#q03e4a48]
+''一般ユーザーで作成する''
 # su - hoge
 $ /usr/local/ssh/bin/ssh-keygen -t rsa                   ← SSH2で公開鍵・秘密鍵を作成
 Generating public/private rsa key pair.
 Enter file in which to save the key (/home/hoge/.ssh/id_rsa): ← 鍵のファイル名を入力(空EnterでOK)
 Created directory '/home/hoge/.ssh'
 Enter passphrase (empty for no passphrase):                  ← パスフレーズの入力
 Enter same passphrase again:                                 ← パスフレーズの再入力
 Your identification has been saved in /home/hoge/.ssh/id_rsa.
 Your public key has been saved in /home/hoge/.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  ← 公開鍵
~
+''公開鍵の名前の変更''~
authorized_keysが既存の場合
 $ 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
~
+''フロッピーにコピー''~
id_rsaファイルをフロッピーにコピーする。([[フロッピーのマウント>CentOS#g375d5fb]]
)
 # cp /home/hoge/.ssh/id_rsa /mnt/floppy
フロッピーにコピーされたid_rsaファイルを使用してPuTTyの接続設定を行う。

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS