Ubuntu上搭建Git服务器
2017-01-15 19:59
344 查看
下面我们就看看,如何在Ubuntu上搭建Git服务器。我们使用VMware虚拟机安装两台Ubantu系统,分别命名为gitServer和gitClient_01。
![](http://static.codeceo.com/images/2015/07/88174978bbc4cf31f27ec13bdda12acc1.png)
通过命令 ps –e|grep ssh,查看ssh服务是否启动。
![](http://static.codeceo.com/images/2015/07/e346c1b3bf63d7354691093ec9567ee51.png)
通过以上命令,我们为Ubantu系统安装SSH服务,并配置SSH无密码登陆,首先我们修改主机和ip配置文件:gedit /ect/hosts
![](http://static.codeceo.com/images/2015/07/db2a01164ebb3a93767d6597e86174e21.png)
![](http://static.codeceo.com/images/2015/07/27f0690bcc778f26e8178f162badc2d91.png)
![](http://static.codeceo.com/images/2015/07/aa237087fbdfc3237efde000a5f4ab961.png)
完成之后,在.ssh目录下,我们可以看到id_rsa和id_rsa.pub文件,id_rsa.pub为公钥,我们通过命令scp /home/git/.ssh/id_rsa.pub gitServer:/home/git将gitClient_01上生成的公钥拷贝到gitServer上。
在gitServer上我们首先查看/home/git/.ssh目录下是否存在authorized_kesys文件,
如果没有,可以通过touch authorized_keys创建此文件。
Authorized_keys创建完成后,将gitClient_01上拷贝过来的公钥id_rsa.pub的内容追加到authroized_keys中,注意是追加到此文件中,可以使用命令cat /home/git/id_rsa.pub>>/home/git/.ssh/authorized_keys.
以上内容完成后,我们在gitClient_01中,可以使用命令ssh gitServer即可完成无密码登陆。
![](http://static.codeceo.com/images/2015/07/ca1c153c755309e88d5f965fc7f1c7361.png)
![](http://static.codeceo.com/images/2015/07/306a8a1cb8246b8a381e2bb41d1ec84d1.png)
![](http://static.codeceo.com/images/2015/07/82061cbeaea0dbc3b39a98946564e34c1.png)
![](http://static.codeceo.com/images/2015/07/d7d391a04c10fe31022fb417c7dd6b361.png)
1、安装OpenSSH并配置SSH无密码登陆
通过命令 sudo apt-get install openssh-server,安装SSH服务。![](http://static.codeceo.com/images/2015/07/88174978bbc4cf31f27ec13bdda12acc1.png)
通过命令 ps –e|grep ssh,查看ssh服务是否启动。
![](http://static.codeceo.com/images/2015/07/e346c1b3bf63d7354691093ec9567ee51.png)
通过以上命令,我们为Ubantu系统安装SSH服务,并配置SSH无密码登陆,首先我们修改主机和ip配置文件:gedit /ect/hosts
![](http://static.codeceo.com/images/2015/07/db2a01164ebb3a93767d6597e86174e21.png)
2、创建用户git,用来管理运行git服务。
![](http://static.codeceo.com/images/2015/07/27f0690bcc778f26e8178f162badc2d91.png)
3、配置无密码SSH登陆
在gitClient_01上,我们使用命令:ssh-keygen –t rsa 生成密钥,如下图![](http://static.codeceo.com/images/2015/07/aa237087fbdfc3237efde000a5f4ab961.png)
完成之后,在.ssh目录下,我们可以看到id_rsa和id_rsa.pub文件,id_rsa.pub为公钥,我们通过命令scp /home/git/.ssh/id_rsa.pub gitServer:/home/git将gitClient_01上生成的公钥拷贝到gitServer上。
在gitServer上我们首先查看/home/git/.ssh目录下是否存在authorized_kesys文件,
如果没有,可以通过touch authorized_keys创建此文件。
Authorized_keys创建完成后,将gitClient_01上拷贝过来的公钥id_rsa.pub的内容追加到authroized_keys中,注意是追加到此文件中,可以使用命令cat /home/git/id_rsa.pub>>/home/git/.ssh/authorized_keys.
以上内容完成后,我们在gitClient_01中,可以使用命令ssh gitServer即可完成无密码登陆。
![](http://static.codeceo.com/images/2015/07/ca1c153c755309e88d5f965fc7f1c7361.png)
4、安装Git
通过命令 sudo apt-get install git-core,安装git![](http://static.codeceo.com/images/2015/07/306a8a1cb8246b8a381e2bb41d1ec84d1.png)
5、建立git仓库的存储目录。
![](http://static.codeceo.com/images/2015/07/82061cbeaea0dbc3b39a98946564e34c1.png)
6、初始化服务器端仓库
使用命令 git –bare init /home/git/myRep.git,初始化化仓库![](http://static.codeceo.com/images/2015/07/d7d391a04c10fe31022fb417c7dd6b361.png)
7、在gitClient_01上,通过git clone命令进行克隆远程仓库,并在各自的电脑上运行开发。
Git clone git@gitServer:/home/git/myRep.git相关文章推荐
- (转)Ubuntu中Git服务器搭建
- Ubuntu下 git 服务器的搭建。
- UbuntuServer搭建Git服务器之git和gitolite(二)
- Ubuntu10.04搭建Git服务器和GitWeb
- ubuntu 12.04 git gitosisi gitolite 服务器搭建相关汇总。
- Ubuntu10.04搭建Git服务器和GitWeb
- Git服务器在Ubuntu中的搭建
- 【git】ubuntu系统下,搭建git服务器环境
- 搭建ubuntu上的git服务器,并用Mac下用Xcode连接进行开发
- 在 Ubuntu 上搭建 git 仓库服务器 gitolite
- Git服务器在Ubuntu中的搭建
- Git服务器在Ubuntu中的搭建
- Ubuntu中Git服务器搭建
- ubuntu搭建Git 服务器
- Ubuntu中Git服务器搭建
- Ubuntu上git服务器的搭建
- Git服务器在Ubuntu中的搭建
- Ubuntu下 git 服务器的搭建。
- ubuntu上git服务器搭建(转载)
- UbuntuServer搭建Git服务器之gitdeamon和gitweb(四)