centos7.0 下安装git(ssh方式)
最近刚弄了个阿里云,在上面弄个git服务器,这里只弄了ssh方式访问,http方式访问的可以看我另外一个随笔http://www.cnblogs.com/hz-cww/p/6077970.html。
1、 安装依赖的库
[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
2、 删除原本的安装的git
[root@localhost ~]# yum remove git -y
3、下载git-2.10.0.tar.gz 到 /usr/local/src
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz
4、 编译安装
[root@localhost src]# tar -zvxf git-2.10.0.tar.gz
[root@localhost src]# cd git-2.10.0
[root@localhost src]# make prefix=/usr/local/git all
[root@localhost src]# make prefix=/usr/local/git install
5、 增加软连接
[root@localhost src]# ln -s /usr/local/git/bin/* /usr/bin/
[root@localhost src]# git --version
如果能正常显示版本号,即表示成功
6、新建git用户和设置密码
[root@localhost ~]# useradd -m git
[root@localhost ~]# passwd git
7、新建git的仓库,并设置权限,我这边是建立repositories这个文件夹
[root@localhost ~]# mkdir -p /home/git/repositories
[root@localhost ~]# chown -R git:git /home/git/repositories
[root@localhost ~]# chmod 755 /home/git/repositories
8、切换到git用户下,新建仓库
[root@localhost ~]# su git
[git@localhost root]$ mkdir /home/git/repositories/test.git
[git@localhost root]$ cd /home/git/repositories/test.git
[git@localhost test.git]$ git --bare init
ok,到这里简单的git服务器已经建立好了,你可以去客户端机子上clone了
地址:ssh://git@这里写你的IP/home/git/repositories/test.git
9、禁用git用户的shell登陆,修改/etc/passwd文件
[root@localhost ~]# vi /etc/passwd
找到这一行
git:x:1001:1001:,,,:/home/git:/bin/bash
将最后一个冒号后改为:
git:x:1001:1001:,,,:/home/git:/usr/src/git-2.10.0/git-shell
这样,git用户可以正常通过ssh使用git,但无法登录shell,因为我们为git用户指定的git-shell每次一登录就自动退出。
10、附加:下一次新建git仓库时,shell只能用root登录
[root@localhost root]$ mkdir /home/git/repositories/test2.git
[root@localhost root]$ cd /home/git/repositories/test2.git
[root@localhost test.git]$ git --bare init
这里新建完之后,必须将新建的git仓库更改所有者为git用户,不然无法连接,执行下面命令,
注意这里-R必须加上,不然git用户clone会出现权限不够问题
[root@localhost ~]# chown -R git:git /home/git/repositories
ok,到这里就基本搞定。
centos7.0 下安装git(ssh方式)的更多相关文章
- centos7.0 下安装git(http方式)
之前弄了个ssh方式访问的git服务器,但是那种方式不太方便,而且网页也访问不了,所以这里又弄个http方式访问的git服务器. 安装过程还和之前一样,这里我再复制一遍,省的再去找了. 1. 安装依赖 ...
- 【CNMP系列】CentOS7.0下安装PHP5.6.30服务
上一节我们讲过了如何在CentOS7.0下安装MySql服务,如果没有看到欢迎页面的朋友,可以加我的个人微信详聊:litao514148204 附上一节地址:http://www.cnblogs.co ...
- CentOS7.0下安装FTP服务的方法
http://www.jb51.net/article/106604.htm 本篇文章主要介绍了CentOS7.0下安装FTP服务的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟 ...
- 【CNMP系列】CentOS7.0下安装MySql5.6服务
接上一回的话,CentOS7.0下安装好了Nginx服务,对于我们的CNMP,我们可以开始我们的M啦,就是传统意义上的MySql服务 MySql简介 MySQL是一个关系型数据库管理系统,由瑞典MyS ...
- 【Linux】CentOS7.0下安装JDK环境
写在前面:此次试验是在CentOS7上面安装的,亲测成功. 所需工具:JDK1.8安装包,xftp 具体步骤: 1,首先使用xftp连接到自己的虚拟机,然后查看是否有"/usr/java/j ...
- 【Tomcat】CentOS7.0下安装多个Tomcat及其配置
安装前所需环境 在开始安装Tomcat之前,需要安装环境JDK,并配置JAVA环境.如果不知道如何配置,可参考这篇博客:[Linux]CentOS7.0下安装JDK环境 Tomcat安装 Tomcat ...
- [转载] Ubuntu 12.04下安装git,SSH及出现的Permission denied解决办法
如何安装ssh http://os.51cto.com/art/201109/291634.htm 仅需要阅读至成功开启ssh服务即可 http://www.linuxidc.com/Linux/20 ...
- 【CNMP系列】CentOS7.0下安装Nginx服务
话步前言,CNMP之路,系统起步:http://www.cnblogs.com/riverdubu/p/6425028.html 这回我来讲解下CentOS7.0下如何安装和配置Nginx服务 Ngi ...
- centos7.0 下安装jdk1.8
centos7.0这里安装jdk1.8采用yum安装方式,非常简单. 1.查看yum库中jdk的版本 [root@localhost ~]# yum search java|grep jdk 2.选择 ...
随机推荐
- 故障review的一些总结
故障review的一些总结 故障review的目的 归纳出现故障产生的原因 检查故障的产生是否具有普遍性,并尽可能的保证同类问题不在出现, 回顾故障的处理流程,并检查处理过程中所存在的问题.并确定此类 ...
- html页面制作css基本设置
html{ height: 100%;} *{ margin: 0; padding: 0;}/* tell the browser to render HTML 5 elements as bloc ...
- 做web开发和测试,修改hosts指定某个域名访问某个特定的IP后,如何使hosts立即生效的方法
本文转自SUN'S BLOG,原文地址:http://whosmall.com/post/143 hosts的配置方法: 在windows系统中,找到C:\windows\system32\drive ...
- 一道javascript数组操作题
题目如下: var arr = ['100px','abc'-6,[],-98765,34,-2,0,'300',,function(){alert(1);}, null, document, [], ...
- 《你不常用的c#之XX》
你不常用的c#之一>:略谈unsafe http://blog.csdn.net/robingaoxb/article/details/6199508 <你不常用的c#之二>:略谈G ...
- JAVA WEB项目中各种路径的获取
JAVA WEB项目中各种路径的获取 标签: java webpath文件路径 2014-02-14 15:04 1746人阅读 评论(0) 收藏 举报 分类: JAVA开发(41) 1.可以在s ...
- juery学习总结——例子
1.select元素在选择是找到选择的值和option中的值 <!DOCTYPE html> <html> <head lang="en"> & ...
- window 使用vagrant搭建开发开发环境
# -*- mode: ruby -*-# vi: set ft=ruby : # All Vagrant configuration is done below. The "2" ...
- 关于struts2的过滤器和mybatis的插件的分析
网上一搜,发现一篇写的非常棒的博文,就直接复制过来了,供以后复习使用. 前辈博文链接:共三篇: http://jimgreat.iteye.com/blog/1616671: http://jimgr ...
- 简单的 MessageBox
有时候我们只是想实现一个消息框,给用户一些文字提醒,就像javascript的alert那样.没必要因此动用那些庞大的GUI库,下面是几种轻快的实现方法. 1. ctypes import ctype ...