`
stephen830
  • 浏览: 2962402 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

ubuntu git 服务器端和客户端的环境配置

    博客分类:
  • git
 
阅读更多

ubuntu git 服务器端和客户端的环境配置

 

 

1.安装 openssh服务器

git默认是使用ssh协议,因此首先检查服务器是否支持ssh,因此首先检查ubuntu服务器是否安装过openssh-server openssh-client(dpkg -l|grep openssh-server , dpkg -l|grep openssh-client),如果没有安装,则执行下面的安装命令:

sudo apt-get install openssh-server openssh-client

 

2.安装 git服务器

ubuntu@10-10-37-22:~$sudo apt-get install git-core

 

创建git服务器管理用户

ubuntu@10-10-37-22:~$sudo useradd -m git
ubuntu@10-10-37-22:~$sudo passwd git

创建git仓库存储目录

ubuntu@10-10-37-22:~$sudo mkdir /home/git/repositories

设置git仓库权限

ubuntu@10-10-37-22:~$sudo chown git:git /home/git/repositories
ubuntu@10-10-37-22:~$sudo chmod 755 /home/git/repositories

初始化全局设置

ubuntu@10-10-37-22:~$git config --global user.name "zjq"
ubuntu@10-10-37-22:~$git config --global user.email "10349xxxx@qq.com"

 

 3.安装python的setup tool
ubuntu@10-10-37-22:~$sudo apt-get install python-setuptools

4.获取并安装gitosis

ubuntu@10-10-37-22:~$ cd /tmp
ubuntu@10-10-37-22:/tmp$ git clone https://github.com/res0nat0r/gitosis.git
ubuntu@10-10-37-22:/tmp$ cd gitosis
ubuntu@10-10-37-22:/tmp/gitosis$ sudo python setup.py install

 

----git管理客户端电脑操作  开始---

创建个人公钥和私钥
在默认用户的主目录路径下,运行以下命令,按照提示创建公钥和私钥
ssh-keygen -t rsa


默认生成2048位,如果需要提高安全级别,也可以通过下面的命令创建公钥和私钥
ssh-keygen -t rsa -b 4096


默认情况下,公钥和私钥会保存在~/.ssh目录下,如下所示:
id_rsa  id_rsa.pub  known_hosts

 

将id_rsa.pub文件上传到上面ubuntu服务器的/tmp目录下

----git管理客户端电脑操作  结束---

 

在ubuntu服务器上准备gitosis

ubuntu@10-10-37-22:~$sudo -H -u git gitosis-init < /tmp/id_rsa.pub
执行后在/home/git/repositories/下会出现gitosis-admin.git文件夹,gitosis同样使用git来进行管理,因此我们需要git clone后修改,并执行commit和push使配置生效。
ubuntu@10-10-37-22:~$sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

----git管理客户端电脑操作  开始---

在管理客户端安装gitosis进行git管理操作
cd ~
mkdir git
cd git
git clone git@hostname:gitosis-admin.git
hostname是上面ubuntu服务器的域名或者ip地址
执行后在 ~/git目录下会出现目录gitosis-admin
cd gitosis-admin
可以看到有1个文件:gitosis.conf   , 1个目录:keydir
 

----git管理客户端电脑操作  结束---

 
 
 
 
 
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics