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. js判断手机的左右滑动

    js代码 $(function() { function judge() { var startx;//让startx在touch事件函数里是全局性变量. var endx; var el = doc ...

  2. c语言中的rewind函数,Win CE 不支持,可用fseek函数替换

    FILE *read = fopen(cXmlFile,"rb"); if (read) { fseek(read, 0L, SEEK_END); int len = ftell( ...

  3. vue 设置头文件

    vue的头文件是在index.html文件中设置的,毕竟vue的入口 先说一下标签页的名字: 就是这个名字的设置,要想每个标签页的名字都不一样,需要做以下这三步:1. 首先,在index.html文件 ...

  4. 牛客网 牛客小白月赛1 E.圆与三角形-公式题

    E.圆与三角形   链接:https://www.nowcoder.com/acm/contest/85/E来源:牛客网     这个题把公式推一下, 发现就是1+sinA*r,sinA最大为1,所以 ...

  5. 大型网站优化-memcache技术

    大型网站优化-memcache技术 memory+cache 内存缓存 memcache简介 memcache是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发 ...

  6. java JIT AOT

    作者:ETIN链接:https://zhuanlan.zhihu.com/p/27393316来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. I guess anyon ...

  7. require_once(): Failed opening required '/var/www/config/config.php' (include_path='.:') in /var/www/vendor/forkiss/pharest/src/Pharest/Register/Register.php on line 10

    环境 docker环境 错误 [Tue Jun 18 18:43:26 2019] 127.0.0.1:53980 [500]: /index.php - require_once(): Failed ...

  8. [译]在IB中实现自动布局

    有关自动布局的其他文章: Autolayout Visual format language for autolayout Creating individual constraints 可怜的界面编 ...

  9. 【IntelliJ IDEA】升级之后又要激活的解决方法

    用了几个月的idea,在它升级之后,又不听话了.启动时候需要重新激活. 解决方法: 1.找到C:\Windows\System32\drivers\etc\下的hosts文件 在文件中添加如下: 0. ...

  10. 2016.7.12 针对不同的数据库类型generatorConfig文件中的数据库配置

    百度了很多资料,没有专门说这个的.大家都是配置自己的数据库,大部分是mysql.因为我使用的是postgresql,还是找了一会才找到配置指导. 毕竟第一次配置,还是要看着别人的指导比较安心.配置完后 ...