服务器端创建 git 用户,用来管理 Git 服务,并为 git 用户设置密码

[root@localhost home]# id git
id: git:无此用户
[root@localhost home]# useradd git
[root@localhost home]# passwd git

 

设置 /home/data/git/gittest.git 为 Git 仓库
然后把 Git 仓库的 owner 修改为 git

[root@localhost home]# mkdir -p data/git/gittest.git
[root@localhost home]# git init --bare data/git/gittest.git
Initialized empty Git repository in /home/data/git/gittest.git/
[root@localhost home]# cd data/git/
[root@localhost git]# chown -R git:git gittest.git/

  

禁用shell登录:
出于安全考虑,第二步创建的git用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:
git:x:1001:1001:,,,:/home/git:/bin/bash
改为:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

git clone、push 提示输入密码但输入后登录被拒绝
客户端创建 SSH 公钥和私钥
$ ssh-keygen -t rsa -C "447313241@qq.com"
由 AuthorizedKeysFile 得知公钥的存放路径是 .ssh/authorized_keys,实际上是 $Home/.ssh/authorized_keys,由于管理 Git 服务的用户是 git,所以实际存放公钥的路径是 /home/git/.ssh/authorized_keys
在 /home/git/ 下创建目录 .ssh

把专用密钥(private and public keys)添加到 ssh-agent 的高速缓存中
ssh-add ~/.ssh/id_dsa
ssh-add -d ~/.ssh/id_xxx.pub
如果执行ssh-add时提示”Could not open a connection to your authentication agent”,可以现执行命令:
ssh-agent bash
然后再执行上述 ssh-add 操作
然后可以进行clone等操作了

push 出错的解决 (branch is currently checked out)
是由于git默认拒绝了push操作,需要进行设置,修改.git/config文件后面添加如下代码:
[receive]
denyCurrentBranch = ignore

git 服务端安装的更多相关文章

  1. git服务端安装

    Windows平台下Git服务器搭建 第一步:下载Java,下载地址:http://www.java.com/zh_CN/  注意要下载是完整的JDK(其中有jre) 第二步:安装Java.安装步骤不 ...

  2. centos 安装git 服务端

    // 在服务端安装好git后,开始安装gitosis 3.在服务器安装gitosis sudo yum install python python-setuptools cd /usr/local/s ...

  3. git的CentOS服务端安装和windows客户端的使用

    git的CentOS服务端安装和windows客户端的使用 此教程以 搬瓦工vps CentOS 6 x64 的系统为环境,搭建 git 服务端.windows 7 系统为客户端. git客户端 在W ...

  4. Centos搭建Git服务端

    首先需要安装git,可以使用yum源在线安装 yum install -y git 创建一个git用户,用来运行管理git服务 adduser git 初始化git仓库(这里我们选择/home/git ...

  5. 开源入侵检测系统OSSEC搭建之一:服务端安装

    OSSEC是一款开源的多平台的入侵检测系统,可以运行于Windows, Linux, OpenBSD/FreeBSD, 以及 MacOS等操作系统中.主要功能有日志分析.完整性检查.rootkit检测 ...

  6. svn服务端安装、权限修改以及客户端的使用

    2017-10-1016:10:2 svn服务端安装.权限修改以及客户端的使用 svn服务端.客户端.汉化包下载 http://pan.baidu.com/s/1c1Ogj2C 1.安装服务器端程序( ...

  7. ssr 服务端安装教程

    1 ShadowsocksR 多用户版服务端安装教程(SS-Panel后端) 2 ShadowsocksR 单用户版服务端安装教程

  8. Zabbix 3.4 服务端安装部署

    关于zabbix的安装部署官方也提供了详细的安装文档,链接如下: https://www.zabbix.com/download 选择zabbix的版本,服务器平台及使用的数据库 安装和配置zabbi ...

  9. centos 7 上zabbix 3.0 服务端安装

    zabbix服务端安装 安装完毕mysql-5.6.php5.6 mysql-5.6安装:https://www.cnblogs.com/xzlive/p/9771642.html  创建zabbix ...

随机推荐

  1. Activiti工作流学习(一)——Activiti服务类

    Activity有9个service1.DynamicBpmnService动态Bpmn服务Service providing access to the repository of process ...

  2. shiro认证-SSM

    shiro认证-SSM pom <dependency> <groupId>org.apache.shiro</groupId> <artifactId> ...

  3. leetcode解题报告(3):Search in Rotated Sorted Array

    描述 Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 m ...

  4. seq2seq聊天模型(二)——Scheduled Sampling

    使用典型seq2seq模型,得到的结果欠佳,怎么解决 结果欠佳原因在这里 在训练阶段的decoder,是将目标样本["吃","兰州","拉面" ...

  5. JavaWeb_(Spring框架)整合Mybatis加入事务操作数据库

    整合Mybatis a)导包: i.Spring:基本包.aop.aspects.jdbc.tx.test: ii.Mybatis:mybatis-3.4.6 iii.整合包:mybatis-spri ...

  6. CF1200A

    CF1200A 解法: 给出长度为n的字符串,字符串由'L'.'R'以及数字0~9组成.旅馆有10间房子,L代表客人从左边入住,R代表客人从右边入住,数字则表示第i间房子客人退房了.问经过这n次操作后 ...

  7. 通过.zip安装eclipse插件

    参考地址https://stackoverflow.com/questions/5482554/how-to-install-plugin-for-eclipse-from-zip

  8. kotlin之map委托

    fun main(arg: Array<String>) { val map = mapOf("name" to "tom", ) val user ...

  9. win7上 nginx 出现 403 Forbidden

    一般是目录权限问题,在conf文件找到 location / { index index.html index.htm index.php;# autoindex on; } 把#去掉就可以了.

  10. LeetCode_9. Palindrome Number

    9. Palindrome Number Easy Determine whether an integer is a palindrome. An integer is a palindrome w ...