OPS Notes By 枯木

Svn and Git Server备忘

| Comments

Git Server with ssh

  • Server
1
2
3
4
5
6
7
useradd -s /usr/bin/git-shell git   //创建git用户
git init --bare /home/git/testrepo  //初始化名为testrepo,Server端操作
mkdir /home/git/.ssh -p
vim .ssh/authorized_keys            //加入客户端ssh公钥,设置ssh公钥认证
chmod 700 /home/git/.ssh/
chmod 400 /home/git/.ssh/authorized_keys
chown git:git -R /home/git

注意:如果是root用户执行的命令,需要修改权限如下

1
chown -R git:git testrepo
  • Client
1
git clone git@sevrer_ip:/home/git/testrepo  //克隆repo

具体操作

1
2
3
4
5
6
cd testrepo                         //进入本地版本库
echo "hello" >> test                //新建测试文件
git add test                        //添加到git缓存
git commit -m "first commit" test   //本地提交
git push -u origin master           //提交给远程服务器
git pull                            //客户端拉取数据

Svn Server with apache && ldap

1
yum install subversion mod_dav_svn -y

yum安装后会生成subversion.conf并添加相应模块配置

1
2
3
# grep LoadModule /etc/httpd/conf.d/subversion.conf 
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

svn创建库

1
2
svnadmin create --fs-type fsfs /var/www/svn
chown apache:apache -R /var/www/svn

设置ldap认证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# grep -vE '^$|^#' /etc/httpd/conf.d/subversion.conf 
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<Location /svn>
    DAV svn
    SVNPath /var/www/svn
    AuthBasicProvider ldap
    AuthType Basic
    AuthzLDAPAuthoritative off
    AuthName "Please provide your windows login credentials to continue."
    AuthLDAPURL "ldap://ldap_ip/ou=users,ou=test,dc=intranet,dc=test,dc=com?sAMAccountName" NONE
    AuthLDAPBindDN "test@intranet.test.com"
    AuthLDAPBindPassword password
    require valid-user
</Location>

启动apache

1
service httpd start

浏览器登陆
http://svn_ip/svn

Comments