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. hdu 4786(生成树)

    Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  2. (4)ASP.NET内置对象1

    一.Response 把数据从服务端发送到客户端 Response.Write() 在页面上输出数据 Response.WriteFile(@"F:\WriteFile.txt") ...

  3. CSU 1777: 大还是小?【模拟/后导0】

    293419 roniking 1777 Accepted 2032 0 C++ 2000 2018-04-03 19:21:25 Description 输入两个实数,判断第一个数大,第二个数大还是 ...

  4. linux文本处理常用命令

    linux文本处理常用命令   linux文本处理命令:grep.sed.printf.awk 1.grep grep的作用是按行查找字符,输出包含字符的行. #从文件查询 grep 'hello' ...

  5. 分布式定时任务调度系统技术解决方案(xxl-job、Elastic-job、Saturn)

    1.业务场景 保险人管系统每月工资结算,平安有150万代理人,如何快速的进行工资结算(数据运算型) 保险短信开门红/电商双十一 1000w+短信发送(短时汇聚型) 工作中业务场景非常多,所涉及到的场景 ...

  6. Implement Trie (Prefix Tree) - LeetCode

    Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs ar ...

  7. BZOJ 3672 NOI 2014 购票

    题面 Description 今年夏天,NOI在SZ市迎来了她30周岁的生日.来自全国 n 个城市的OIer们都会从各地出发,到SZ市参加这次盛会. 全国的城市构成了一棵以SZ市为根的有根树,每个城市 ...

  8. Scut游戏服务器引擎6.5.8.6发布

    1.增加从Redis中加载数据到Cache可设置筛选条件2.修改在Web项目中的不能支持自定协议问题3.修改Share类型的Model在Redis中为空时会尝试从DB中加载数据4.修改Model命名空 ...

  9. 矩阵快速幂计算hdu1575

    矩阵快速幂计算和整数快速幂计算相同.在计算A^7时,7的二进制为111,从而A^7=A^(1+2+4)=A*A^2*A^4.而A^2可以由A*A得到,A^4可以由A^2*A^2得到.计算两个n阶方阵的 ...

  10. python局部变量与全局变量

    name = "head first python"def what_happens_here():    print(name)  1    name = "pytho ...