Windows上使用Cygwin和Gitolite搭建Git服务器

简介:

原文:http://alone11.iteye.com/blog/1078297

安装Cygwin

  1. 下载 setup.exe
  2. 打开setup.exe, 选择Install from Internet
  3. 选择安装Cygwin到C:\cygwin
  4. 选择存储下载文件的目录为C:\
  5. 选择下载站点的镜像
  6. 选择安装以下软件包:
    • Net | openssh (不要选成openssl)
    • Devel | git
    • Devel | git-completion
    • Devel | git-gui
    • Devel | git-svn (如果需要同时提交到svn)
    • Devel | gitk
    • Editors | vim

集成Cygwin和Windows Security

  1. 打开C:\cygwin\Cygwin.bat
  2. $ 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)
  3. 选择yes
  4. 重启Windows

搭建SSH服务器

  1. 打开C:\cygwin\Cygwin.bat
  2. $ 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)
  3. 选择yes
    *** 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)
  4. 选择yes
    *** 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)
  5. 选择yes
    *** Query: Enter the value of CYGWIN for the daemon: []
  6. 输入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!
  7. 配置结束,确认端口22可用。启动服务:sc start sshd

允许SSH客户端访问

  1. 创建一个名为git的用户,设置密码,并确保密码不会过期。
  2. 在Cygwin Bash中,执行命令: mkpasswd -l -u git >> /etc/passwd

验证下SSH登录

  1. 打开Cygwin Bash
  2. $ ssh git@10.0.2.15
    Administrator@china-fe1bdcde5 ~
    $ ssh git@10.0.2.15
    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.
    git@10.0.2.15'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 ~
    $
  3. 以git用户登录成功

创建SSH密钥, 并使能够通过SSH identity以git用户登录SSH服务器

 

  1. 打开Cygwin Bash
  2. $ 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. |
    +-----------------+
  3. $ ssh-copy-id git@10.0.2.15 (输入git用户密码)
    $ ssh-copy-id git@10.0.2.15
    git@10.0.2.15's password:
    Now try logging into the machine, with "ssh 'git@10.0.2.15'", and check in:

    ~/.ssh/authorized_keys

    to make sure we haven't added extra keys that you weren't expecting.
  4. 验证下,以git用户登录:ssh git@10.0.2.15
    $ ssh git@10.0.2.15
    Last login: Sat Jun 11 23:06:14 2011 from china-fe1bdcde5

    git@china-fe1bdcde5 ~
    $
  5. 不需要输入密码,即登录成功

安装Gitolite

  1. 打开Cygwin Bash
  2. $ cd /tmp
  3. $ git clone git://github.com/sitaramc/gitolite.git
  4. $ cd gitolite/src/
  5. $ ./gl-easy-install git 10.0.2.15 alec (可以单独执行gl-easy-install查看各个参数的意义)
  6. 根据安装向导一步步完成配置(其中需要配置alec的密码,生成SSH密钥)
  7. 当走到需要编辑配置文件(用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
  8. 继续完成安装。当完成安装之后,可以在当前用户的home目录下面看到gitolite-admin目录。
  9. $ cd ~/gitolite-admin
  10. $ git status
    Administrator@china-fe1bdcde5 ~/gitolite-admin
    $ git status
    # On branch master
    nothing to commit (working directory clean)

到此整个git server已经安装结束,可以参考Gitolite文档来配置:添加user和repository

 


相关文章
|
2月前
|
Shell Linux 网络安全
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
506 3
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
|
5月前
|
SQL Apache Windows
Windows服务器80端口被占用的全面解决方案
在服务管理器中启动apache2服务,即可正常使用80端口。若系统中还安装了其他微软产品如sql等,也可尝试停止其服务进行测试,但请注意,SQL通常不会使用80端口,因此一般不会受到影响。以上就是关于80端口被system占用的详细解决方法,希望对你有所帮助。
|
5月前
|
Windows
Windows下版本控制器(SVN)-验证是否安装成功+配置版本库+启动服务器端程序
Windows下版本控制器(SVN)-验证是否安装成功+配置版本库+启动服务器端程序
162 2
|
6月前
|
Windows
Windows下版本控制器(SVN)-启动服务器端程序
Windows下版本控制器(SVN)-启动服务器端程序
228 4
|
5月前
|
监控 Linux 网络安全
FinalShell SSH工具下载,服务器管理,远程桌面加速软件,支持Windows,macOS,Linux
FinalShell是一款国人开发的多平台SSH客户端工具,支持Windows、Mac OS X和Linux系统。它提供一体化服务器管理功能,支持shell和sftp同屏显示,命令自动提示,操作便捷。软件还具备加速功能,提升访问服务器速度,适合普通用户和专业人士使用。
1618 0
|
7月前
|
存储 安全 Ubuntu
从Linux到Windows:阿里云服务器系统镜像适配场景与选择参考
阿里云为用户提供了丰富多样的服务器操作系统选择,以满足不同场景下的应用需求。目前,云服务器的操作系统镜像主要分为公共镜像、自定义镜像、共享镜像、镜像市场和社区镜像五大类。以下是对这些镜像类型的详细介绍及选择云服务器系统时需要考虑的因素,以供参考。
|
6月前
|
安全 Shell 开发工具
Windows下使用git配置gitee远程仓库
就在前几天因为一些原因,我的电脑重装了系统,然后再重新配置git的环境的时候就遇到了一些小问题。所以我决定自己写一篇文章,以便以后再配置git时,避免一些错误操作,而导致全网搜方法,找对的文章去找对应的解决方法。下面为了演示方便就拿gitee来演示,不拿GitHub了写文章了。
310 0
|
2月前
|
弹性计算 运维 安全
阿里云轻量应用服务器与云服务器ECS啥区别?新手帮助教程
阿里云轻量应用服务器适合个人开发者搭建博客、测试环境等低流量场景,操作简单、成本低;ECS适用于企业级高负载业务,功能强大、灵活可扩展。二者在性能、网络、镜像及运维管理上差异显著,用户应根据实际需求选择。
285 10
|
2月前
|
运维 安全 Ubuntu
阿里云渠道商:服务器操作系统怎么选?
阿里云提供丰富操作系统镜像,涵盖Windows与主流Linux发行版。选型需综合技术兼容性、运维成本、安全稳定等因素。推荐Alibaba Cloud Linux、Ubuntu等用于Web与容器场景,Windows Server支撑.NET应用。建议优先选用LTS版本并进行测试验证,通过标准化镜像管理提升部署效率与一致性。
|
2月前
|
弹性计算 ice
阿里云4核8g服务器多少钱一年?1个月和1小时价格,省钱购买方法分享
阿里云4核8G服务器价格因实例类型而异,经济型e实例约159元/月,计算型c9i约371元/月,按小时计费最低0.45元。实际购买享折扣,1年最高可省至1578元,附主流ECS实例及CPU型号参考。
431 8

热门文章

最新文章