原文:http://alone11.iteye.com/blog/1078297
安裝cygwin
下載下傳 setup.exe
打開setup.exe, 選擇install from internet
選擇安裝cygwin到c:\cygwin
選擇存儲下載下傳檔案的目錄為c:\
選擇下載下傳站點的鏡像
選擇安裝以下軟體包:
net | openssh (不要選成openssl)
devel | git
devel | git-completion
devel | git-gui
devel | git-svn (如果需要同時送出到svn)
devel | gitk
editors | vim
內建cygwin和windows
security
打開c:\cygwin\cygwin.bat
$ bin/cyglsa-config
warning: registering the cygwin lsa authentication package requires administrator privileges! you also have to reboot the machine to activate the change.
are you sure you want to continue? (yes/no)
選擇yes
重新開機windows
搭建ssh伺服器
$ ssh-host-config
*** info: generating /etc/ssh_host_key
*** info: generating /etc/ssh_host_rsa_key
*** info: generating /etc/ssh_host_dsa_key
*** info: generating /etc/ssh_host_ecdsa_key
*** info: creating default /etc/ssh_config file
*** info: creating default /etc/sshd_config file
*** info: privilege separation is set to yes by default since openssh 3.3.
*** info: however, this requires a non-privileged account called 'sshd'.
*** info: for more info on privilege separation read /usr/share/doc/openssh/readme.privsep.
*** query: should privilege separation be used? (yes/no)
*** info: note that creating a new user requires that the current account have
*** info: administrator privileges. should this script attempt to create a
*** query: new local account 'sshd'? (yes/no)
*** info: updating /etc/sshd_config file
*** info: added ssh to c:\windows\system32\driversc\services
*** warning: the following functions require administrator privileges!
*** query: do you want to install sshd as a service?
*** query: (say "no" if it is already installed as a service) (yes/no)
*** query: enter the value of cygwin for the daemon: []
輸入tty
*** info: the sshd service has been installed under the localsystem
*** info: account (also known as system). to start the service now, call
*** info: `net start sshd' or `cygrunsrv -s sshd'. otherwise, it
*** info: will start automatically after the next reboot.
*** info: host configuration finished. have fun!
配置結束,确認端口22可用。啟動服務:sc start sshd
允許ssh用戶端通路
建立一個名為git的使用者,設定密碼,并確定密碼不會過期。
在cygwin bash中,執行指令: mkpasswd -l -u git >> /etc/passwd
驗證下ssh登入
打開cygwin bash
$ ssh [email protected]
administrator@china-fe1bdcde5 ~
the authenticity of host '10.0.2.15 (10.0.2.15)' can't be established.
ecdsa key fingerprint is 5d:a6:81:98:43:fa:5a:f6:df:ba:18:b9:a0:76:87:f8.
are you sure you want to continue connecting (yes/no)? yes
warning: permanently added '10.0.2.15' (ecdsa) to the list of known hosts.
[email protected]'s password:
could not chdir to home directory /home/git: no such file or directory
copying skeleton files.
these files are for the users to personalise their cygwin experience.
they will never be overwritten nor automatically updated.
`./.bashrc' -> `/home/git//.bashrc'
`./.bash_profile' -> `/home/git//.bash_profile'
`./.inputrc' -> `/home/git//.inputrc'
`./.profile' -> `/home/git//.profile'
git@china-fe1bdcde5 ~
$
以git使用者登入成功
建立ssh密鑰, 并使能夠通過ssh identity以git使用者登入ssh伺服器
$ ssh-keygen -t rsa (所有輸入都為空,即使用預設配置,密碼為空)
$ ssh-keygen -t rsa
generating public/private rsa key pair.
enter file in which to save the key (/home/administrator/.ssh/id_rsa):
enter passphrase (empty for no passphrase):
enter same passphrase again:
your identification has been saved in /home/administrator/.ssh/id_rsa.
your public key has been saved in /home/administrator/.ssh/id_rsa.pub.
the key fingerprint is:
6a:02:9f:42:99:7c:fe:52:e7:a9:fe:1b:15:1e:70:31 administrator@china-fe1bdcde5
the key's randomart image is:
+--[ rsa 2048]----+
| . e. |
| o . |
| o |
| . o . o |
| * . s o |
| . = ..... |
| . =.oo.. |
| ..+ o. |
| o+oo. |
+-----------------+
$ ssh-copy-id [email protected] (輸入git使用者密碼)
$ ssh-copy-id [email protected]
now try logging into the machine, with "ssh '[email protected]'", and check in:
~/.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
驗證下,以git使用者登入:ssh [email protected]
last login: sat jun 11 23:06:14 2011 from china-fe1bdcde5
不需要輸入密碼,即登入成功
安裝gitolite
$ cd /tmp
$ git clone git://github.com/sitaramc/gitolite.git
$ cd gitolite/src/
$ ./gl-easy-install git 10.0.2.15 alec (可以單獨執行gl-easy-install檢視各個參數的意義)
根據安裝向導一步步完成配置(其中需要配置alec的密碼,生成ssh密鑰)
當走到需要編輯配置檔案(用vim編輯)的時候,在開頭插入:$env{path} = "/usr/local/bin:/bin:/usr/bin";,儲存并退出(:wq) 如:
# configuration variables for gitolite
$env{path} = "/usr/local/bin:/bin:/usr/bin";
# please read the documentation before editing or asking questions
# ( http://github.com/sitaramc/gitolite/blob/pu/doc/gitolite.rc.mkd )
# ( or http://sitaramc.github.com/gitolite/doc/gitolite.rc.html )
# this file is in perl syntax. however, you do not need to know perl to edit
# it; it should be fairly self-explanatory and easy to maintain
繼續完成安裝。當完成安裝之後,可以在目前使用者的home目錄下面看到gitolite-admin目錄。
$ cd ~/gitolite-admin
$ git status
administrator@china-fe1bdcde5 ~/gitolite-admin
# on branch master
nothing to commit (working directory clean)
到此整個git server已經安裝結束,可以參考gitolite文檔來配置:添加user和repository