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

 


相关文章
|
27天前
|
存储 开发工具 git
[Git] 深入理解 Git 的客户端与服务器角色
Git 的核心设计理念是分布式,每个仓库既可以是客户端也可以是服务器。通过 GitHub 远程仓库和本地仓库的协作,Git 实现了高效的版本管理和代码协作。GitHub 作为远程裸仓库,存储项目的完整版本历史并支持多客户端协作;本地仓库则通过 `.git` 文件夹独立管理版本历史,可在离线状态下进行提交、回滚等操作,并通过 `git pull` 和 `git push` 与远程仓库同步。这种分布式特性使得 Git 在代码协作中具备强大的灵活性和可靠性。
51 18
[Git] 深入理解 Git 的客户端与服务器角色
|
28天前
|
网络安全 Apache 开发工具
图解Git——服务器上的Git《Pro Git》
Git 远程仓库及通信协议简介:远程仓库为团队协作提供平台,支持共享代码。常见形式为裸仓库,仅保存 Git 元数据。Git 支持多种协议,包括本地协议(适合局域网)、HTTP/HTTPS(推荐智能 HTTP,安全易用)、SSH(企业内部协作首选)和 Git 协议(高效只读访问)。选择协议需根据协作需求、安全性和配置难度权衡。此外,搭建 Git 服务器涉及创建裸仓库、上传至服务器、初始化共享仓库等步骤。生成 SSH 公钥、配置服务器及使用 GitWeb 或 GitLab 等工具可进一步增强功能。第三方托管服务如 GitHub 提供便捷的托管选项,适合快速启动和开源项目。总结而言,自行运行服务器提
38 11
|
1月前
|
存储 Java 数据库
windows server2016搭建AD域服务器
windows server2016搭建AD域服务器
138 72
|
3月前
|
Android开发 数据安全/隐私保护 虚拟化
安卓手机远程连接登录Windows服务器教程
安卓手机远程连接登录Windows服务器教程
541 4
|
3月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
143 4
|
4月前
|
Apache 数据中心 Windows
将网站迁移到阿里云Windows系统云服务器,访问该站点提示连接被拒绝,如何处理?
将网站迁移到阿里云Windows系统云服务器,访问该站点提示连接被拒绝,如何处理?
|
4月前
|
域名解析 缓存 网络协议
Windows系统云服务器自定义域名解析导致网站无法访问怎么解决?
Windows系统云服务器自定义域名解析导致网站无法访问怎么解决?
|
4月前
|
弹性计算 安全 Windows
通过远程桌面连接Windows服务器提示“由于协议错误,会话将被中断,请重新连接到远程计算机”错误怎么办?
通过远程桌面连接Windows服务器提示“由于协议错误,会话将被中断,请重新连接到远程计算机”错误怎么办?
|
3天前
|
机器学习/深度学习 人工智能 程序员
阿里云出手DeepSeek拒绝服务器繁忙,程序员直呼:真香!
阿里云PAI平台支持一键部署DeepSeek-V3和DeepSeek-R1大模型,用户无需编写代码即可完成从训练到部署的全过程。通过PAI Model Gallery,开发者可轻松选择并部署所需模型版本,享受高效、便捷的AI开发体验。教程详细介绍了开通PAI、选择模型及一键部署的具体步骤,帮助用户快速上手。
|
4天前
|
机器学习/深度学习 存储 弹性计算
阿里云gpu云服务器租用价格:最新收费标准及活动价格参考
阿里云gpu云服务器多少钱?A10卡GN7i GPU云服务器32核188G3213.99/1个月起,V100卡GN6v GPU云服务器8核32G3830.00/1个月起,阿里云GPU云服务器是基于GPU应用的计算服务,多适用于视频解码,图形渲染,深度学习,科学计算等应用场景,该产品具有超强计算能力、网络性能出色、购买方式灵活、高性能实例存储( GA1和GN5特有)等特点。下面小编来介绍下阿里云gpu云服务器最新的收费标准及活动价格。