Git Server 搭建

本文将介绍如何在一台windows系统的机器上搭建Git的服务器。

一.安装cygwin

cygwin是用于在windows系统下模拟linux的环境。

  1. 首先,下载安装包 http://www.cygwin.com/ 开始安装
    图片描述
  2. 点击 next 继续
    图片描述
  3. 选择 Install from Internet,点击next
    图片描述
  4. 选择安装目录,一般默认就好,点击next
    图片描述
  5. 选择存储库的目录
    图片描述
  6. 选择Direct Connection,点击next
    图片描述
  7. 选择一个站点,点击next
    图片描述
  8. 输入要安装的包,这里我们需要git, openssh, cygrunsrv和vim, 点击next 等待安装完成。

二.Connecting Cygwin to Windows Security

  1. 右键安装好的cygwin,选择以管理员身份运行
  2. 执行 /bin/cyglsa-config 输入 yes
  3. 重启系统

三.设置SSH 服务器

1. 执行ssh-host-config
* Info: Generating /etc/ssh_host_key
* Info: Generating /etc/ssh_host_rsa_key
* Info: Generating /etc/ssh_host_dsa_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)
Type 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)
Type yes.
* Info: Updating /etc/sshd_config file
* 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)
Type yes.
* Query: Enter the value of CYGWIN for the daemon: []
Type 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 2003 Server or later. On 2003
* Info: and later 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)
Type no.
* Query: Create new privileged user account 'cyg_server'? (yes/no)
Type 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.
Type password.

2. 防火墙设置:
Open the Windows Firewall and create an exception for port 22/tcp.
goto: Control PanelSystem and SecurityWindows Firewall
goto: advanced settings
goto: inbound rules: rigth click “new rule” tcp port 22
goto: outbound rules: rigth click “new rule” tcp port 22

3. 执行cygrunsrv -S sshd 启动service。

四.创建ssh认证

执行ssh-user-config生成秘钥
* Query: Shall I create an SSH1 DSA identity file for you? (yes/no)
Type no.
* Query: Shall I create an SSH2 RSA identity file for you? (yes/no)
Type yes.
* Info: Generating /home/agross/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
Type and confirm a passphrase. You can omit the passphrase if you want, but that makes you less secure when you loose your private key file.
Type no for all the below.

五.安装Gitolite

  1. 进入home\git目录(这里git为用户名)
  2. mkdir -p ~/bin
  3. git clone https://github.com/sitaramc/g...
  4. gitolite/install -ln ~/bin #please use absolute path here
  5. gitolite setup -pk yourname.pub

Notes:
yourname.pub can not be the public key of the server PC.

六.测试

使用你的admin用户进行clone:git clone git@gitserver:gitolite-admin.git
clone下来的gitolite-admin下有keydir目录用于放其他用户的公钥,conf/gitolite.conf文件用于配置权限。

七.卸载

  1. Open c:/cygwin/cygwin.bat
  2. Execute cd c:
  3. Execute rm -r cygwin --no-preserve-root
  4. Close cygwin.bat, delete c:/cygwin
  5. Open cmd, execute sc delete sshd
  6. Open regedit, delete HKEY_CURRENT_USERSoftwareCygwin and HKEY_LOCAL_MACHINESOFTWARECygwin
  7. Right click My Computer, click manage, go to System Tools/Local Users and Groups/Users, delete cyg-server and sshd user
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值