• git 服务端安装


    服务器端创建 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

  • 相关阅读:
    mysql主从之双主配置
    mysql主从之binlog的工作模式
    mysql主从之主机名导致主从机制失败的问题
    python_文件 处理
    python_字典 学习
    python_元组 学习
    python 基础内置函数表及简单介绍
    python 列表学习
    python函数基础学习
    python迭代器、生成器、列表推倒式
  • 原文地址:https://www.cnblogs.com/lauhp/p/9486517.html
Copyright © 2020-2023  润新知