Windows + Cygwin 環境でsshクライアントを使用するため
OpenSSH をインストール・セットアップしたので忙備録として。
作業にあたっては
guro chan さんの日記 を参考にさせて頂いた。
Vista環境ではコマンドプロンプトを起動する際「管理者として実行」することを忘れずに。
まずは cygwin のインストーラで openssh と diffutils をインストールする。
インストールしたら一応 cygcheck コマンドで確認。
$ cygcheck -c openssh
Cygwin Package Information
Package Version Status
openssh 5.1p1-3 OK
$ cygcheck -c diffutils
Cygwin Package Information
Package Version Status
diffutils 2.8.7-1 OK
確認したら ssh-host-config コマンドを実行。
$ ssh-host-config
そうすると次の確認メッセージが表示される。
*** Query: Should privilege separation be used? (yes/no)
先の参考サイトに従って yes を応答する。
すると私の環境ではボリュームマウントエラーとなった。
*** Warning: The SYSTEM user cannot access the mount point /usr/bin.
*** Warning: Please run the following command to add a system mount point:
*** Warning: mount -f -s -b "[DOS path to Cygwin]/bin" "/usr/bin"
*** Warning: where [DOS path to Cygwin] is something like c:/cygwin.
*** Warning:
*** Warning: For more information, run 'mount -m' and 'mount -h'
*** Warning: The SYSTEM user cannot access the mount point /usr/lib.
*** Warning: Please run the following command to add a system mount point:
*** Warning: mount -f -s -b "[DOS path to Cygwin]/lib" "/usr/lib"
*** Warning: where [DOS path to Cygwin] is something like c:/cygwin.
*** Warning:
*** Warning: For more information, run 'mount -m' and 'mount -h'
*** Warning: The SYSTEM user cannot access the mount point /.
*** Warning: Please run the following command to add a system mount point:
*** Warning: mount -f -s -b "[DOS path to Cygwin]/" "/"
*** Warning: where [DOS path to Cygwin] is something like c:/cygwin.
*** Warning:
*** Warning: For more information, run 'mount -m' and 'mount -h'
*** Warning: It appears that you have user mode mounts ("Just me" chosen
*** Warning: during install.) Any daemons installed as services will fail
*** Warning: to function unless system mounts are used. To change this,
*** Warning: re-run setup.exe and choose "All users".
*** Warning:
*** Warning: For more information, see http://cygwin.com/faq/faq0.html#TOC33
*** ERROR: Problem with mount points. Exiting画面に従ってディレクトリをマウントする。
$ mount -f -s -b "c:\cygwin\bin" "/usr/bin"
$ mount -f -s -b "c:\cygwin\lib" "/usr/lib"
$ mount -f -s -b "c:\cygwin" "/"
再び ssh-host-config コマンドを実行。
先程の "Should privilege 〜" のメッセージに引き続き、パーミッションエラーが出た。
*** Warning: The file /etc/passwd is not readable by all.
*** Warning: Please run 'chmod +r /etc/passwd'.
*** Warning: The file /etc/group is not readable by all.
*** Warning: Please run 'chmod +r /etc/group'.
*** ERROR: Problem with LocalSystem or Adminstrator IDs
メッセージに従い粛々とパーミッションを変更する。
$ chmod +r /etc/passwd
$ chmod +r /etc/group
三度 ssh-host-config を実行。
今度は /var のパーミッションで弾かれた。
*** Warning: The permissions on the directory /var are not correct.
*** Warning: They must match the regexp d..x..x..[xt]
*** ERROR: Problem with /var directory. Exiting.
ので、大人しくパーミッション変更。
$ chmod 111 /var
四度目の正直。ssh-host-config が漸く通過。
sshdアカウントを作成するか聞いてくるが、今回はsshサーバを建てる訳ではないので no を返す。
sshdをサービスとして実行するか聞いてくるので、これも no。
*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no)
すると・・・
*** Info: Host configuration finished. Have fun!
漸く OpenSSH のセットアップが完了。
早速 ssh コマンドで目的のサーバにリモートログインしてみると、
見事接続できた。パチパチ。
guro chanさんに感謝。