zoukankan      html  css  js  c++  java
  • linux git server 简易搭建 (ssh访问)

    git的服务器搭建,如果无需权限控制,仅团队内部使用,初始化一个服务器仓库,其他人通过ssh访问这个文件夹即可。如需复杂的管理,建议使用gitlab

    yum install git -y
    
    id git
    useradd git
    
    su git
    cd
    mkdir .ssh && chmod 700 .ssh
    touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
    cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys
    
    mkdir -p /opt/git/repo.git
    git init --bare /opt/git/repo.git
    chown -R git:git /opt/git
    
    
    cat /etc/shells # see if `git-shell` is already in there. If not...
    which git-shell # make sure git-shell is installed on your system.
    vim /etc/shells # and add the path to git-shell from last command
    chsh git # and enter the path to git-shell, usually: /usr/bin/gitshell
    
    git clone git@ip:/opt/git/repo.git

    使用ssh -T git@ip 会看到一个提示

    fatal: Interactive git shell is not enabled.
    hint: ~/git-shell-commands should exist and have read and execute access.

    下面我们可定制欢迎信息,可通过git help shell查看到帮助。

    创建文件 /home/git/git-shell-commands/no-interactive-login

    内容如下:

    #!/bin/sh
    printf '%s
    ' "Hi $USER! You've successfully authenticated, but I do not"
    printf '%s
    ' "provide interactive shell access."
    exit 128

    配置权限:

    chmod 500 /home/git -R
    chown git:git /home/git -R
    

    再使用ssh -T git@ip ,提示会显示欢迎信息:

    Hi git! You've successfully authenticated, but I do not
    provide interactive shell access.

    参考:

    https://www.cnblogs.com/dee0912/p/5815267.html

    https://git-scm.com/book/zh/v2 - 服务器上的git

    git help shell

  • 相关阅读:
    BZOJ1864: [Zjoi2006]三色二叉树
    2019牛客全国多校训练四 I题 string (SAM+PAM)
    2019杭电多校第二场
    HDU5919 Sequence II(主席树)
    2019牛客全国多校训练三 题解
    2019牛客多校第二场
    2019 杭电多校第一场 题解
    2019 牛客全国多校一
    POJ3261 Milk Patterns(后缀数组)
    POJ1743 Musical Theme (后缀数组 & 后缀自动机)最大不重叠相似子串
  • 原文地址:https://www.cnblogs.com/wswind/p/10399248.html
Copyright © 2011-2022 走看看