Ubuntu server 搭建Git server

简介:

Ubuntu server 搭建Git server,git相比svn,最主要就是分布式了,每个客户端用户的本地都是一个版本管理控制器。

  Ubuntu server 版本为12.04

  搭建步骤如下:

  1、更新Ubuntu server

  操作如下:

  $ apt-get update

  $ apt-get upgrade

  如上命令更新并升级系统,防止在安装git过程中,出现部分依赖包没有安装。

  

  2、安装openssh的server和client

  其实通常情况下,Ubuntu server都默认安装了openssh。安装SSH的目的,SSH 协议用于为 Git 提供远程读写操作,是远程写操作的标准服务,ssh可用于远程登录,服务端需要安装openssh-server,客户端需要安装openssh-client。介绍ssh协议是因为gitolite以及gitosis都是基于ssh公钥认证的。

  安装openssh之前,可以先查看是否安装过

  $ ps -ef | grep ssh

  如果没有,就继续如下安装步骤,

  $ sudo apt-get install openssh-server openssh-client

  

  3、安装git

  $ sudo apt-get install git-core  

  安装完毕即可!

 

  4、配置git用户

  在Ubuntu Server上新增一个git用户,用于为安装gitosis做准备

  $ sudo adduser --system --shell /bin/bash --group git  // 创建用户 git,并设置用户的 shell 为可登录的 shell,如 /bin/bash,同时添加同名的用户组。

  $ sudo adduser git ssh  // 有的系统,只允许特定的用户组(如 ssh 用户组)的用户才可以通过 SSH 协议登录,这就需要将新建的 git 用户添加到 ssh 用户组中。

  $ sudo passwd git  // 为 git 用户设置口令。

  $ ssh-copy-id git@server  // 管理员在客户端使用下面的命令,建立无口令登录。 

 

  5、创建git Server的仓库存储

  $ sudo mkdir /home/git/repositories  // 创建git仓库存储目录

  $ sudo chown git:git /home/git/repositories  // 设置只允许git用户才能访问此目录

  $ sudo chmod 755 /home/git/repositories  // 设置目录访问的可读写或执行的权限

  初始化一下服务器的git用户,这一步其实是为了安装gitosis做准备。在任何一 台客户端机器上使用git,第一次需要初始化一下:

  $ git config --global user.name "name"       // 例如:james

  $ git config --global user.email "name@server"   // 例如:james@yahoo.com

  

  6、获取Gitosis,并安装

  Gitosis 就是一套用来管理 authorized_keys文件和实现简单连接限制的脚本。简单地说,Gitosis就是git的权限策略控制器。  

  因为Gitosis源码安装方式通过python方式,所以这里要检测是否安装了python的setup tool,没有即安装此工具, 这个也是为了gitosis做准备:

  $ sudo apt-get install python-setuptools

  去到一个临时目录

  $ cd /tmp

  $ git clone https://github.com/res0nat0r/gitosis.git  // 下载Gitosis的源代码

  $ cd /tmp/gitosis

  $ sudo python setup.py install

  

  说明:Gitosis有一个改进的升级版Gitolite,这里以安装Gitosis为标准,所以不对Gitolite介绍。Gitosis安装完之后,即Git服务器就安装完成,接下来,需要为Git设置一个管理员,通过Gitosis初始化之后,才能正常使用Git作为版本控制进行相关版本管理。

  下一节,将详细描述通过创建Git管理员来初始化Git Server,并详细描述Git在Windows下作为客户端如何使用。

 

 

  

  








本文转自一米一阳光博客园博客,原文链接: http://www.cnblogs.com/candle806/p/4064610.html   ,如需转载请自行联系原作者



相关文章
|
6月前
|
Ubuntu 安全 Linux
百度搜索:蓝易云【Ubuntu 20.04 安装VNC Server的教程。】
请注意,VNC连接是以明文形式传输数据的,因此建议在安全的网络环境中使用VNC,并设置强密码以确保安全性。
188 1
|
7月前
|
网络安全 开发工具 文件存储
在群晖NAS上快速搭建属于自己的Git Server
在群晖NAS上快速搭建属于自己的Git Server
888 0
|
Kubernetes 网络协议 Ubuntu
Kubeadm 快速搭建 k8s v1.19.1 集群(Ubuntu Server 20.04 LTS)
安装准备工作安装环境要求:角色 实验环境 生产环境 操作系统 master cpu/内存:2 Core/2G cpu/内存:2 Core/4G linux 内核 4.4+ node cpu/内存:1 Core/2G cpu/内存:4 Core/16G linux 内核 4.4+ 备注 Node:应根据需要运行的容器数量进行配置; Linux 操作系统基于 x86_64 架构的各种 Linux 发行版...
955 2
Kubeadm 快速搭建 k8s v1.19.1 集群(Ubuntu Server 20.04 LTS)
|
5月前
|
存储 缓存 NoSQL
如何解决Ubuntu server 下 Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”.
如何解决Ubuntu server 下 Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”.
129 0
|
1月前
|
存储 Ubuntu 网络安全
|
4月前
|
Ubuntu Linux 开发工具
Linux Ubuntu配置Git的方法
Linux Ubuntu配置Git的方法
|
4月前
|
Ubuntu 网络安全 虚拟化
【Ubuntu】Win11 VmWare虚拟机安装Ubuntu 22.04.1-server
【Ubuntu】Win11 VmWare虚拟机安装Ubuntu 22.04.1-server
112 1
【Ubuntu】Win11 VmWare虚拟机安装Ubuntu 22.04.1-server
|
7月前
|
消息中间件 网络协议 Ubuntu
Ubuntu安装RabbitMQ server - 在外远程访问【内网穿透】
通过在ubuntu+cpolar+rabbitMQ环境下,实现mq服务端远程访问。
Ubuntu安装RabbitMQ server - 在外远程访问【内网穿透】
|
7月前
|
Ubuntu
树莓派 ubuntu server 22.x 连接无线网络
树莓派 ubuntu server 22.x 连接无线网络
94 0
|
8月前
|
开发工具 git
Git 使用小乌龟(TortoiseGit)拉取Github项目时报错【server sent :publickey】
Git 使用小乌龟(TortoiseGit)拉取Github项目时报错【server sent :publickey】
175 0