Git 可以使用四种主要的协议来传输数据:本地传输,SSH 协议,Git 协议和 HTTP 协议

1,安装:

CentOS/Fedora: yum install git

Ubuntu/Debian: apt-get install git

创建一个git用户,用来运行git服务

useradd git passwd git 

找一个目录,创建一个裸仓库

git init --bare your-project.git chown -R git:git your-project.git 

客户端连接:

ssh-keygen -t rsa -C "youremail@mailprovider.com" 

根据提示输入密码。windows可用PuTTY Gen生成。

将你的id_rsa.pub上传到git服务器,然后用cat命令将内容拷贝到授权文件中。注意a single '>' will overwrite all the contents of the second file you specify. A double '>' will append it。

创建.ssh目录,然后创建authorized_keys文件,

mkdir /home/git/.ssh	 touch /home/git/.ssh/authorized_keys cat id_ras.pub >> authorized_keys 

If you want to add others to your access list, they simply need to give you their id_rsa.pub key and you append it to the authorized keys file.一行一个

Git服务器打开RSA认证

在Git服务器上首先需要将/etc/ssh/sshd_config中将RSA认证打开,即:

RSAAuthentication yes      PubkeyAuthentication yes      AuthorizedKeysFile  .ssh/authorized_keys 

%h/.ssh: %h is replaced by the home directory of the user being authenticated
service sshd restart 

authorized_keys文件的作用是什么?

一般懂Linux的朋友可能知道了,它是用来做SSH免密码登录配置的,在客户端生成一个RSA或者其他加密方式的公钥和私钥,

然后将公钥传至Linux服务端,保存到authorized_keys文件,这样,客户端在SSH远程登录的时候,就不需要输入密码验证了。

git clone git@192.168.8.34:/data/git/learngit.git 

测试

vim test.c git add test.c git commit -m "test" git push -u origin master 

艺搜参考

https://github.com/elesos/progit/blob/master/zh/04-git-server/01-chapter4.markdown 有GitWeb的介绍

CentOS搭建git服务器实测的更多相关文章

  1. 在CentOS搭建Git服务器 转

    在CentOS搭建Git服务器 来自 :http://www.jianshu.com/p/69ea5ded3ede 前言 我们可以GitHub发布一些开源代码的公共仓库,但对于私密仓库就需要收费了.公 ...

  2. CentOS搭建Git服务器及权限管理

    声明:本教程,仅作为配置的记录,细节不展开,需要您有一点linux的命令基础,仅作为配置参考. 1. 系统环境 系统: Linux:CentOS 7.2 64位 由于CentOS已经内置了OpenSS ...

  3. 在centos搭建git服务器时,不小心把/home/git目录删除了,我是怎么恢复的

    在centos搭建git服务器时,不小心把/home/git目录删除了,我是怎么恢复的 在删除掉/home/git目录后,每次 git push提交时,都让填写密码,烦 第一步:在本地找到id_rsa ...

  4. centos 搭建git服务器

    centos 6搭建git服务器 安装 rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm yum ins ...

  5. 自定义Git之使用centos搭建git 服务器

    Github 公开的项目是免费的,但是如果你不想让其他人看到你的项目就需要收费. 这时我们就需要自己搭建一台Git服务器作为私有仓库使用. 接下来我们将以 Centos 为例搭建 Git 服务器. 1 ...

  6. Centos搭建 Git 服务器教程

    搭建 GIT 服务器教程 下载安装 git Git 是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. 此实验以 CentOS 7.2 x64 的系统为环境,搭建 git 服 ...

  7. CentOS 搭建 Git 服务器

    官方文档移步 Git 服务器的搭建 安装 Git #yum install git 创建 Git 专用用户 #useradd git,改密码 #passwd git,切换至 Git 用户 #su gi ...

  8. CentOS搭建GIT服务器

    安装git # 请确保您切换到了root账户 $ su root $ yum install -y git # 验证是否安装成功 $ git --version # 输出如下内容表示成功: git v ...

  9. centos搭建git服务器(转)

    一:git服务安装 1.安装git相关组件 [root@gitserver ~] yum -y install git 2.创建git用户 [root@gitserver ~] groupadd gi ...

随机推荐

  1. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---10

    以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:

  2. os模块 文件操作

    下面的方法可以在python程序里直接生成文件到系统路径(windows环境下测试): <<<<<<要注意字符串前面要加字母r>>>>> ...

  3. 链表ADT的实现

    list.h文件 /*链表的类型声明*/ typedef int ElementType; /* START: fig3_6.txt */ #ifndef _List_H #define _List_ ...

  4. 误加all_load引起的程序报错

    一.为什么要加-all_load 在64位的mac系统和iOS系统下,链接器有一个bug,会导致只包含有类别的静态库无法使用-ObjC标志来加载文件.解决方法是使用-all_load或者-force_ ...

  5. 迷宫问题(DFS,BFS)

    /******************************** 啊哈!算法 深度优先搜索算法 迷宫问题 输入: 5 4 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 ...

  6. CentOS 7下安装配置FTP

    安装vsftpd yum install -y vsftpd 编辑ftp配置文件 vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO #anonymous_e ...

  7. Jave工具——servlet+jsp编程中mysql数据库连接及操作通用工具类

    该工具类是在JavaWeb中连接mysql所用到的通用工具类 该类用于Java+Servlet的编程中,方便数据库的操作,连接,获取其列表值.下面是这个数据库操作类的通用方法,基本上能够用于类里面只含 ...

  8. ajax简单案例

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  9. delphi中如何将string类型的字符串数据转化成byte[]字节数组类型的数据

    var  S:String;  P:PChar;  B:array of Byte;begin  S:='Hello';  SetLength(B,Length(S)+1);  P:=PChar(S) ...

  10. 【spring boot logback】日志logback格式解析

    日志logback格式解析 logback官网 格式解析 https://logback.qos.ch/manual/layouts.html#ClassicPatternLayout 官网格式解析有 ...