Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126277
  • 博文数量: 21
  • 博客积分: 898
  • 博客等级: 准尉
  • 技术积分: 236
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-22 10:32
文章存档

2011年(8)

2010年(1)

2009年(6)

2008年(6)

我的朋友

分类: WINDOWS

2011-11-28 17:48:41

    经过两个星期的反复折腾,终于在本机上(Win7)实现gitolite服务,并使
TortoiseGit+msysGit管理gitolite的用户和访问gitolite版本库。发布此
文留作纪念。
 
一、安装TortoiseGit
 
 
二、安装msysGit
 
完成后设置TortoiseGit的git可执行文件路径
 
 
三、安装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,重启
~
$ 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.
~
$
 
七、ssh-host-config
~
$ 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!
~
$
 
八、开启sshd服务
~
$ sc start sshd
SERVICE_NAME: sshd
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 2  START_PENDING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x2
        WAIT_HINT          : 0x1388
        PID                : 2644
        FLAGS              :
~
$
 
九、*重新配置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
3.同样方法重新产生用户mok.pub和mok.ppk(名字随意)
4.复制git.pub到C:\cygwin\tmp下
5.到cygwin控制台
~
$ ssh
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).
password:
Last login: Mon Nov 28 17:18:44 2011 from ::1
~
$ 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/
[master (root-commit) 24a0739] start
 2 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100644 conf/gitolite.conf
 create mode 100644 keydir/git.pub
~
$
 
十二、检出权限管理仓库
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.提交
3.push,成功后提示在服务器端自动创建版本库
 
十三、用户检出版本库,进行正常的commit/push等

阅读(12805) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~