EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

萧闫子 发表于 2014-1-10 10:09:24

[开发管理] win7下cygwin+gitolite搭建git服务器,客户端TortoiseGit+msysGit访问

经过两个星期的反复折腾,终于在本机上(Win7)实现gitolite服务,并使
用TortoiseGit+msysGit管理gitolite的用户和访问gitolite版本库。发布此
文留作纪念。

一、安装TortoiseGit
http://blog.chinaunix.net/attachment/201111/28/20775138_1322473947sJDx.jpg


二、安装msysGit
http://blog.chinaunix.net/attachment/201111/28/20775138_1322476693wm3N.jpg
http://blog.chinaunix.net/attachment/201111/28/20775138_13224767027Yy5.jpg
http://blog.chinaunix.net/attachment/201111/28/20775138_1322476727i80W.jpg
http://blog.chinaunix.net/attachment/201111/28/20775138_1322476736mTCG.jpg

完成后设置TortoiseGit的git可执行文件路径

http://blog.chinaunix.net/attachment/201111/28/20775138_1322476864PkIn.jpg


三、安装cygwin
安装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
Python| python


四、把C:\cygwin加入环境变量中

五、创建win7用户,名为git,设置密码(注:用户名随意)

六、cyglsa-config,选择yes,重启
AreMok@AreMok-PC ~
$ 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
Cygwin LSA authentication package registered.
Activating Cygwin's LSA authentication package requires to reboot.
AreMok@AreMok-PC ~
$

七、ssh-host-config
AreMok@AreMok-PC ~
$ 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) yes
*** Info: Updating /etc/sshd_config file
*** 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: [] tty
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.You need to have or to create a privileged
*** Info: account.This script will help you do so.
*** Info: You appear to be running Windows XP 64bit, Windows 2003 Server,
*** Info: or later.On these systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).
*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.
*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.
*** Info: No privileged account could be found.
*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'cyg_server'? (yes/no) yes
*** Info: Please enter a password for new user cyg_server.Please be sure
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.
*** Query: Please enter the password:
*** Query: Reenter:
*** Info: User 'cyg_server' has been created with password 'cyg'.
*** Info: If you change the password, please remember also to change the
*** Info: password for the installed services which use (or will soon use)
*** Info: the 'cyg_server' account.
*** Info: Also keep in mind that the user 'cyg_server' needs read permissions
*** Info: on all users' relevant files for the services running as 'cyg_server'.
*** Info: In particular, for the sshd server all users' .ssh/authorized_keys
*** Info: files must have appropriate permissions to allow public key
*** Info: authentication. (Re-)running ssh-user-config for each user will set
*** Info: these permissions correctly. [Similar restrictions apply, for
*** Info: instance, for .rhosts files if the rshd server is running, etc].

*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account.To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'.Otherwise, it will start automatically
*** Info: after the next reboot.
*** Info: Host configuration finished. Have fun!
AreMok@AreMok-PC ~
$

八、开启sshd服务
AreMok@AreMok-PC ~
$ sc start sshd
SERVICE_NAME: sshd
      TYPE               : 10WIN32_OWN_PROCESS
      STATE            : 2START_PENDING
                              (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
      WIN32_EXIT_CODE    : 0(0x0)
      SERVICE_EXIT_CODE: 0(0x0)
      CHECKPOINT         : 0x2
      WAIT_HINT          : 0x1388
      PID                : 2644
      FLAGS            :
AreMok@AreMok-PC ~
$

九、*重新配置sshd服务(默认的sshd服务无法正确管理gitolite用户)
1.$ cygrunsrv -R sshd
2.$ cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd -u "cyg_server" -w "cyg" -e "PATH=/usr/local/bin:/usr/sbin:/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/system32/Wbem"
3.$ sc start sshd

十、安装gitolite
1.$ git clone git://github.com/sitaramc/gitolite.git
2.$ mkdir -p /usr/local/gitolite/conf /usr/local/gitolite/hooks
3.$ gitolite/src/gl-system-install /usr/local/bin /usr/local/gitolite/conf /usr/local/gitolite/hooks

十一、配置gitolite服务器
1.开始->TortoiseGit->puttygen产生key,复制key中的内容到文本文件中,并重新命名为git.pub
2.点击"Save private Key",保存为git.ppk
http://blog.chinaunix.net/attachment/201111/28/20775138_1322475181NM31.jpg
3.同样方法重新产生用户mok.pub和mok.ppk(名字随意)
4.复制git.pub到C:\cygwin\tmp下
5.到cygwin控制台
AreMok@AreMok-PC ~
$ ssh git@localhost
Could not create directory '/home/AreMok/.ssh'.
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is 57:7b:ee:40:e6:bf:0b:9b:9a:74:b4:c8:29:c3:10:af.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/AreMok/.ssh/known_hosts).
git@localhost's password:
Last login: Mon Nov 28 17:18:44 2011 from ::1
git@AreMok-PC ~
$ gl-setup /tmp/git.pub
The default settings in the rc file (/home/git/.gitolite.rc) are fine for most
people but if you wish to make any changes, you can do so now.
hit enter...
creating gitolite-admin...
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
creating testing...
Initialized empty Git repository in /home/git/repositories/testing.git/
start
2 files changed, 6 insertions(+), 0 deletions(-)
create mode 100644 conf/gitolite.conf
create mode 100644 keydir/git.pub
git@AreMok-PC ~
$

十二、检出权限管理仓库
http://blog.chinaunix.net/attachment/201111/28/20775138_1322475625ssaB.jpg
1.桌面上生成gitolite-admin的文件夹,把mok.pub复制到gitolite-admin/keydir/下,修改gitolite-admin/conf/gitolite.conf文件如下,
repo    gitolite-admin
      RW+   =   git
repo    testing
      RW+   =   @all
repo    mdm3001s
      RW+   =   mok      
2.提交
http://blog.chinaunix.net/attachment/201111/28/20775138_13224758713fFW.jpg
3.push,成功后提示在服务器端自动创建版本库
http://blog.chinaunix.net/attachment/201111/28/20775138_13224759136QZ5.jpg
http://blog.chinaunix.net/attachment/201111/28/20775138_1322475920XEbK.jpg

十三、用户检出版本库,进行正常的commit/push等
http://blog.chinaunix.net/attachment/201111/28/20775138_1322476070to3O.jpg
页: [1]
查看完整版本: [开发管理] win7下cygwin+gitolite搭建git服务器,客户端TortoiseGit+msysGit访问