Linux 下搭建git 服务器

环境: 服务器 centos7.3 +git1.8.3.1
客户端 centos7.2 +git1.8.3.1
服务器配置;
1.安装git yum install git -y
2.创建git用户
    [[email protected] ~]# id git
    id: git: no such user
    [[email protected] ~]# useradd git
    [[email protected] ~]# id git
    uid=1001(git) gid=1001(git) groups=1001(git)

为了安全起见,可以只允许git使用git命令

sed -i ‘/^git/s#/bin/bash#/usr/bin/git-shell#g‘ /etc/passwd
3.在服务端创建git仓库
把/data/git/test.git设置为GIT仓库,并修改属主属组为git
    [[email protected] ~]# mkdir -p /data/git/test.git
    [[email protected] ~]# git init --bare /data/git/test.git #--bare参数创建目录结构
    Initialized empty Git repository in /data/git/test.git/
    [[email protected] ~]# chown -R git.git /data/git/test.git
    [[email protected] ~]# cd /data/git/test.git/
    [[email protected] test.git]# ll
    total 12
    drwxr-xr-x. 2 git git 6 Jun 28 22:57 branches
    -rw-r--r--. 1 root root 66 Jun 28 22:58 config
    -rw-r--r--. 1 git git 73 Jun 28 22:57 description
    -rw-r--r--. 1 git git 23 Jun 28 22:57 HEAD
    drwxr-xr-x. 2 git git 242 Jun 28 22:57 hooks
    drwxr-xr-x. 2 git git 21 Jun 28 22:57 info
    drwxr-xr-x. 4 git git 30 Jun 28 22:57 objects
    drwxr-xr-x. 4 git git 31 Jun 28 22:57 refs

客户端配置:
1.安装git yum install git -y
2.配置免密钥登录
    [[email protected] ~]#ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    ac:be:d1:12:37:89:1b:ca:52:8b:4c:b7:97:38:18:41 [email protected]
    The key‘s randomart image is:
    +--[ RSA 2048]----+
    |   E                      |
    |  .                        |
    |   .                       |
    |    .    o .              |
    |   o o + S            |
    |   o B = O .         |
    |     = B B .          |
    |       . + o            |
    |         o.              |
    +--------------------+
    [[email protected] ~]# ssh-copy-id 192.168.138.133
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    [email protected]‘s password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh ‘192.168.138.133‘"
    and check to make sure that only the key(s) you wanted were added.
3.创建本地仓库
    [[email protected] ~]# mkdir /git
    [[email protected] ~]# cd /git/
    [[email protected] git]# ll
    total 0
    [[email protected] git]# git clone 192.168.138.133:/data/git/test.git/
    Cloning into ‘test‘...
    warning: You appear to have cloned an empty repository.
    [[email protected] git]# ll
    total 0
    drwxr-xr-x. 3 root root 17 Jul 3 20:42 test

时间: 2024-08-24 21:40:44

Linux 下搭建git 服务器的相关文章

在Linux下搭建Git服务器的方法是什么样?

第一步 安装git:可以通过命令的方式快速安装,不同的linux的安装方法可能不一样,我的是采用的yum方法.ubuntu可以用apt-get命令. sudo yum install git 第二步 添加git用户,因为git服务器只限定来做项目代码交流的,专门开出一个用户来访问git服务器,比较好管理和控制. sudo adduser git 第三步 设置git用户的登陆密码.因为git提供ssh协议登陆功能,网上有的采用了存储客户端rsa_pub密码的方式来免密登陆,但是我按照这个方法存储了

在 Linux 下搭建 Git 服务器

环境: 服务器 CentOS6.6 + git(version 1.7.1)客户端 Windows10 + git(version 2.8.4.windows.1) ① 安装 Git Linux 做为服务器端系统,Windows 作为客户端系统,分别安装 Git 服务器端: #yum install -y git 安装完后,查看 Git 版本 [[email protected] ~]# git --version git version 1.7.1 客户端: 下载 Git for Window

linux下搭建git服务器

1.安装git yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel yum install git 2.接下来我们 创建一个git用户组和用户,用来运行git服务: groupadd git adduser git -g git 3.把我们的公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个. 如果没有该文件创建它: $ cd /home/gi

在Centos7下搭建Git服务器

简介 Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件. Torvalds 开始着手开发 Git 是为了作为一种过渡方案来替代 BitKeeper,后者之前一直是 Linux 内核开发人员在全球使用的主要源代码工具. 开放源码社区中的有些人觉得BitKeeper

Linux下搭建DNS服务器

一.修改Linux主机名 1.hostname 主机名 [[email protected] named]# hostname ifs.com 2.vi /etc/hosts [[email protected] named]# vi /etc/hosts 127.0.0.1 ns.ifs.com ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 ~ 3.vim /etc/sysconfi

Windows操作系统下搭建Git服务器和客户端。

本文将介绍如何在Windows操作系统下搭建Git服务器和客户端.服务器端采用的是Bonobo Git Server,一款用ASP.NET MVC开发的Git源代码管理工具,界面简洁,基于Web方式配置,简单易用.客户端是采用的TortoiseGit工具,UI操作,省去输入命令的麻烦,对于windows用户来说更易于使用. 所需软件: Git服务器端: BONOBO GIT SERVER,下载最新版:http://bonobogitserver.com/ Git客户端: msysgit,下载最新

Linux下搭建DHCP服务器

一.DHCP所需软件包dhcp-common-4.1.1-34.Pl.el6.centos.x86_64dhcp-4.1.1-34.pl.el6.centon.x86_64二.编辑主配置文件 vi/etc/dhcp/dhcpd.conf ddns-update-style interim; ignore client-updates; shared-network ifs {        option domain-name     "ifs.com";        option 

Linux下搭建Apache服务器(完整版)

Linux下搭建Apache服务器(完整版) 什么是Apache? Apache Licence是著名的非盈利开源组织Apache采用的协议.该协议和BSD类似,同样鼓励代码共享和尊重原作者的著作权,同样允许代码修改,再发布(作为开源或商业软件).需要满足的条件也和BSD类似 Apache主要特点 1.开放源代码.跨平台应用 2.支持多种网页编程语言 3.模块化设计 .运行稳定.良好的安全性 Apache软件版本 1.X  1.目前最高版本是1.3,运行稳定  2.向下兼容性较好,但缺乏一些较新

Windows平台下搭建Git服务器的图文教程

Git没有客户端服务器端的概念,但是要共享Git仓库,就需要用到SSH协议(FTP , HTTPS , SFTP等协议也能实现Git共享,此文档不讨论),但是SSH有客户端服务器端,所以在windows下的开发要把自己的Git仓库共享出去的话,就必 须做SSH服务器 Git服务现在独树一帜,相比与SVN有更多的灵活性,最流行的开源项目托管网站Github上面,如果托管开源项目,那么就是免费使用的,但是闭源的项目就会收取昂贵的费用,如果你不缺米,那么不在本文讨论的范围内,既然这样,我们可以自己搭建