Install GitServer Using SSH shared access in Linux

Source: Internet
Author: User
Using HTTP in Git is the permission of Webserver, and using SSH is the permission of each account. (permission issues may occur in the object directory of Git.) If multiple users share the permission, there are several methods to use SSH: Create a new account (git) for unified management by the git account (commitpush) and so on.

Using HTTP in Git is the permission of the Web server, and using SSH is the permission of each account. (permission issues may occur in the Git object directory)

SSH can be used to share multiple users:

  1. Create a new account (Git), Managed by git accounts (commit/push), etc.
  2. Use gitosis for Management (gitosis can set "who" can access this project ).
  3. Use gitolite for Management (gitolite can set who can access this project, and can set which bra can only be accessedNcH and other paths)

What is this article? Idea.

Prepare relevant materials
  • System: Debian/Ubuntu Linux
  • Server:ExAmple.com
  • Project name: project_name
  • Git Repository:/var/cache/git
System kit installation
  • Apt-get install git-core
    Generate an SSH Public Key
    1. Ssh-keygen-t rsa# GenerateId_ Rsa, id_rsa.pub
    2. MvId_rsa ~ /. Ssh/# Place id_rsa IN ~ /. Ssh/internal.
    3. SCpId_rsa.pub example.com:/tmp/id_rsa_user1.pub # Drop id_rsa.pub to the Server, and all public keys must be uploaded to the Server.
    Git Server settings
    1. Ssh example.com
    2. ADdUser git -- disablEd-Password # create a git account and execute all the actions by git to avoid permission issues.
    3. Su-Git # Switch to git Permissions
    4. Cd;Mkdir. Ssh
    5. Add your public key (the problem of remote git login will be solved later)
    6. Cat/Tmp/id_rsa_user1.pub> ~ /. Ssh/authorized_keys
    7. Cat/tmp/id_rsa_user2.pub> ~ /. Ssh/authorized_keys
    8. ? : Commit/push will retain the name of the original commit user, not git
    Create Git Repository
    1. Ssh example.com
    2. Su-git
    3. Mkdir-p/var/cache/git/project_name.git
    4. Cd/var/cache/git/project_name.git
    5. Git init -- bare -- shared
    Add information to Git Repository

    In your computer, either of the following two methods can be used:

    1. Git clone git@example.com:/var/cache/git/project_name.git
    2. Cd project_name
    3. Vim test.txt
    4. Git add.
    5. Git commit-m'add test.txt'
    6. Git push origin master

    Or

    1. Mkdir project_name
    2. Cd project_name
    3. Git init
    4. Git add.
    5. Git commit-m'initial commit'
    6. Git remote add origin git@example.com:/var/cache/git/project_name.git
    7. Git push origin master
    Avoid Git Account Login (security issues)
    • Vim/etc/Passwd# Modify/bin/sh =>/usr/bin/git-shell. git-shell can only perform git operations, but cannot Login.
      Set

      git:x:1000:1000::/home/git:/bin/sh

      Change

      git:x:1000:1000::/home/git:/usr/bin/git-shell

      You can.

    Frequently Used instruction notes
    • Clone: git clone git@example.com:/var/cache/git/project_name.git
    • Commit & Push: git push
    • Command for the first time Commit/Push: git push origin master

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.