sshd cygwin 再インストール まとめ
Windows 7 (64)で sshd を動かすためには。
- cygwin のインストール
http://www.kkaneko.com/rinkou/cygwin/cygwin.html を参考に「CYGWIN バージョンのインストール」の1〜15を行う。
そのときに openssh と cygrunsrv も入れること。
(後で apt-cyg install openssh とかやってもいいけど)
- cygwin terminal を管理者権限で実行し下記コマンドを実行。
$ ssh-host-config (-y オプションは付けない)
Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
Query: Should privilege separation be used? (yes/no) yes
Query: Do you want to install sshd as a service?
Query: (Say "no" if it is already installed as a service) (yes/no) yes
Query: Enter the value of CYGWIN for the daemon: []
Query: Do you want to use a different name? (yes/no) yes
Query: Enter the new user name: cygwin
Query: Reenter: cygwin
Query: Create new privileged user account 'cygwin'? (yes/no) yes
Query: Please enter the password: xxxxxx
Query: Reenter: xxxxxx
長いのでQuery以外は省略してます。
ここでは Windows 特権ユーザ(privilege server)を作り、Unixユーザアカウント名に cygwin passwd は xxxxxx を用いています。
↓
cygwin:xxxx:xx:xx:Privileged server,xxx\cygwin,xxx:/var/empty:/bin/false
として、Windows で c:\cygwin\home に cygwin, cygwin\Git というフォルダを作ります。
cygwin:xxxx:xx:xx:Privileged server,xxx\cygwin,xxx:/home/cygwin:/bin/bash
cygwin terminal で /etc/sshd_config を下記のように変更
↓
#PermitRootLogin yes
#StrictModes no
:
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeyFile .ssh/authorized_keys
さらに公開鍵認証に限定させるためには、http://gentoo.reichsarchiv.jp/item/17 を参考に、
PermitRootLogin no
StrictModes yes
:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeyFile .ssh/authorized_keys
↓
#RhostsRSAAuthentication no
#PasswordAuthentication yes
#PermitEmptyPasswords no
#ChallengeResponseAuthentication yes
とする。(未確認)
RhostsRSAAuthentication no
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
- cygwin terminal(先ほどの管理者権限のterminal)で下記を実行
$ cd /home/cygwin/Git; touch git-daemon-export-all-ok (最初に一回だけ必要)
$ git daemon --export-all --enable=receive-pack --base-path=/home/cygwin/Git/
- RSAキーの作成(本当はコピーしちゃいけないとかだけど)
一般ユーザでの cygwin terminal で RSAキーを作成
$ ssh-keygen.exe -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kageyu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/kageyu/.ssh/id_rsa.
Your public key has been saved in /home/kageyu/.ssh/id_rsa.pub.特権ユーザ cygwin terminal で
あとは、cygwin の /home/kageyu/.ssh/id_rsa, id_rsa.pub を Windows ユーザの c:\Users\kageyu\.ssh\ にコピーして出来上がり。
$ mkdir /home/cygwin/.ssh
$ chmod 700 /home/cygwin/.ssh
/home/kageyu/.ssh/id_rsa.pub を /home/cygwin/.ssh/authorized_keys にコピー
$ chmod 600 /home/cygwin/.ssh/authorized_keys
$ chown -R cygwin /home/cygwin/.ssh/
- TortoiseGitで c:\cygwin\home\cygwin\Git 以下にディレクトリを作成し「Git ここにリポジトリを作成」とか
- TortoiseGitで 「Git Push(リモートへ反映)」とか
ssh://cygwin@xx.xx.xx.xx/home/cygwin/Git/Documents/Bank.git/